@SuppressWarnings("unchecked")
 @Override
 public IntervalAndSubIntervals<T> cloneShallow() {
   IntervalAndSubIntervals<T> clone = (IntervalAndSubIntervals<T>) super.cloneShallow();
   clone.reset();
   return clone;
 }
  @SuppressWarnings("unchecked")
  @Override
  public IntervalAndSubIntervals<T> clone() {
    IntervalAndSubIntervals<T> copy = (IntervalAndSubIntervals<T>) super.clone();
    copy.reset();

    for (T m : this) {
      T mcopy = (T) m.clone();
      mcopy.setParent(copy);
      copy.add(mcopy);
    }

    return copy;
  }
  /** Apply a variant. */
  @Override
  @SuppressWarnings("unchecked")
  public IntervalAndSubIntervals<T> apply(Variant variant) {
    if (!shouldApply(variant)) return this;

    IntervalAndSubIntervals<T> newMarker = (IntervalAndSubIntervals<T>) super.apply(variant);
    if (newMarker == null) return null;
    newMarker.reset();

    for (T m : this) {
      T mcopy = (T) m.apply(variant);

      // Do not add if interval is completely removed
      if (mcopy != null) {
        mcopy.setParent(newMarker);
        newMarker.add(mcopy);
      }
    }

    return newMarker;
  }