public static <T extends HasLongSortKey> Iterator<T> mergeIterators(List<? extends Iterator<T>> iterators,
    Comparator<T> tieBreaker) {
    return switch (iterators.size()) {
      case 0 -> Collections.emptyIterator();
      case 1 -> iterators.get(0);
      case 2 -> new TwoWayMerge<>(iterators.get(0), iterators.get(1), tieBreaker);
      case 3 -> new ThreeWayMerge<>(iterators.get(0), iterators.get(1), iterators.get(2), tieBreaker);
      default -> new KWayMerge<>(iterators, tieBreaker);
    };
  }
Merges sorted iterators into a combined iterator over all the items.
planetiler-core/src/main/java/com/onthegomap/planetiler/collection/LongMerger.java