MarkupIterator<T> () { T t1 = iterator1.hasNext() ? iterator1.peek() : null; T t2 = iterator2.hasNext() ? iterator2.peek() : null; if (t1 == null) { return iterator2; } if (t2 == null) { return iterator1; } int compare = comparator.compare(t1, t2); return compare < 0 ? iterator1 : iterator2; }