presto-main/src/main/java/io/prestosql/operator/WorkProcessorUtils.java/WorkProcessorUtils/flatMap
class WorkProcessorUtils:    static <T, R> WorkProcessor<R> flatMap(WorkProcessor<T> processor, Function<T, WorkProcessor<R>> mapper)
    {
        requireNonNull(processor, "processor is null");
        requireNonNull(mapper, "mapper is null");
        return processor.flatTransform(element -> {
            if (element == null) {
                return TransformationState.finished();
            }

            return TransformationState.ofResult(mapper.apply(element));
        });
    }