private static <T> Supplier<Stream<T>> makeExactSeries(Supplier<Stream<Stream<T>>> sequences, Supplier<LongStream> seriesSizes) {
        return () -> {
            List<Iterator<T>> iterators = sequences.get().map(s -> s.iterator()).toList();

            class BatchIterator<T2> implements Iterator<T2> {
                private final long limit;
                private final Iterator<T2> it;
                private long index = 0;

                public BatchIterator(long limit, Iterator<T2> it) {
                    this.limit = limit;
                    this.it = it;
                }

                @Override
                public boolean hasNext() {
                    return this.index < this.limit && this.it.hasNext();
                }

                @Override
                public T2 next() {
                    this.index++;
                    return this.it.next();
                }
            }

            return mapIndexed(() -> seriesSizes.get().mapToObj(x -> x), (n, s) -> new BatchIterator<T>(s, iterators.get(n % iterators.size())))
                .get().flatMap(it -> StreamSupport.stream(Spliterators.spliteratorUnknownSize(it, 0), false));
        };
    }
Test scenarios to cover OffsetKeyedTreeMap data structure

orderings (M)
 - ascending
 - descending
 - random
<p>
modification scenarios (P)
 - all insertions (n)
 - all insertions, then all remove (different series proportions n,m)
 - intermixed insertions and remove (different series proportions n,m)
 - all insertions, then apply offset at existing key
 - all insertions, then apply offset at missing key
 - intermixed insertions, remove, apply offset (different series proportions n,m,p)
 - all insertions, then removeAtRange at existing key
 - all insertions, then removeAtRange offset at missing key
 - intermixed insertions, removeAtRange, apply offset (different series proportions n,m,p)
<p>
inspection scenarios (Q)
 - find existing key
 - find missing key
 - find existing key and iterate forward/backward till the end/head
 - find missing key and iterate forward/backward till the end/head
 - random backward-forward iterations
<p>
test/org.jkiss.dbeaver.model.lsm.test/src/org/jkiss/dbeaver/model/lsm/test/OffsetKeyedTreeMapTest.java