public List<Interval> insert(List<Interval> intervals, Interval newInterval) {

    ListIterator<Interval> iter = intervals.listIterator();
    while (iter.hasNext()) {
      Interval curt = iter.next();

      if (newInterval.end < curt.start) {
        iter.previous();
        iter.add(newInterval);
        return intervals;

      } else if (newInterval.start > curt.end) {
        continue;

      } else {
        newInterval.start = Math.min(curt.start, newInterval.start);
        newInterval.end = Math.max(curt.end, newInterval.end);
        iter.remove();
      }
    }

    intervals.add(newInterval);
    return intervals;
  }