static <T> Stream<T> iteratorToFiniteStream(final Iterator<T> iterator) {
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, 0), false);
}
static <T> Stream<T> iteratorToInfiniteStream(final Iterator<T> iterator) {
return Stream.generate(iterator::next);
}