presto-main/src/main/java/io/prestosql/server/protocol/Query.java/Query/findCancelableLeafStage
class Query:    private static Optional<Integer> findCancelableLeafStage(QueryInfo queryInfo)
    {
        // if query is running, find the leaf-most running stage
        return queryInfo.getOutputStage().flatMap(Query::findCancelableLeafStage);
    }