presto-main/src/main/java/io/prestosql/execution/QueryStateMachine.java/QueryStateMachine/isScheduled
class QueryStateMachine:    private static boolean isScheduled(Optional<StageInfo> rootStage)
    {
        if (!rootStage.isPresent()) {
            return false;
        }
        return getAllStages(rootStage).stream()
                .map(StageInfo::getState)
                .allMatch(state -> (state == StageState.RUNNING) || state.isDone());
    }