presto-jdbc/src/main/java/io/prestosql/jdbc/PrestoResultSet.java/PrestoResultSet/flatten
class PrestoResultSet:    private static <T> Iterator<T> flatten(Iterator<Iterable<T>> iterator, long maxRows)
    {
        Stream<T> stream = Streams.stream(iterator)
                .flatMap(Streams::stream);
        if (maxRows > 0) {
            stream = stream.limit(maxRows);
        }
        return stream.iterator();
    }