private <T extends Expression> List<T> selectSubqueries(
      PlanBuilder subPlan, Expression parent, List<T> candidates) {
    SuccessorsFunction<Node> recurse =
        expression -> {
          if (!(expression instanceof Expression)
              || (!analysis.isColumnReference((Expression) expression)
                  && // no point in following dereference chains
                  !subPlan.canTranslate(
                      (Expression)
                          expression))) { // don't consider subqueries under parts of the expression
            // that have already been handled
            return expression.getChildren();
          }

          return ImmutableList.of();
        };

    Iterable<Node> allSubExpressions = Traverser.forTree(recurse).depthFirstPreOrder(parent);

    return candidates.stream()
        .filter(candidate -> stream(allSubExpressions).anyMatch(child -> child == candidate))
        .filter(candidate -> !subPlan.canTranslate(candidate))
        .collect(toImmutableList());
  }
Find subqueries from the candidate set that are children of the given parent and that have not
already been handled in the subplan
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/SubqueryPlanner.java