@Override
    public T next() {
      if (heap.isEmpty()) {
        throw new NoSuchElementException();
      }
      int id = heap.peekId();
      T result = items[id];
      Iterator<T> iterator = iterators[id];
      if (iterator.hasNext()) {
        T next = iterator.next();
        items[id] = next;
        heap.updateHead(next.key());
      } else {
        heap.poll();
        items[id] = null;
      }
      return result;
    }
Merges sorted iterators into a combined iterator over all the items.
planetiler-core/src/main/java/com/onthegomap/planetiler/collection/LongMerger.java