presto-main/src/main/java/io/prestosql/execution/StageInfo.java/StageInfo/addAllStages
class StageInfo:    private static void addAllStages(Optional<StageInfo> stageInfo, ImmutableList.Builder<StageInfo> collector)
    {
        stageInfo.ifPresent(stage -> {
            collector.add(stage);
            stage.getSubStages().stream()
                    .forEach(subStage -> addAllStages(Optional.ofNullable(subStage), collector));
        });
    }