private PlanNode removeFirstRecursive(PlanNode node) {
    node = lookup.resolve(node);

    if (where.test(node)) {
      checkArgument(
          node.getChildren().size() == 1,
          "Unable to remove plan node as it contains 0 or more than 1 children");
      return node.getChildren().get(0);
    }
    if (recurseOnlyWhen.test(node)) {
      List<PlanNode> sources = node.getChildren();
      if (sources.isEmpty()) {
        return node;
      }
      if (sources.size() == 1) {
        return replaceChildren(node, ImmutableList.of(removeFirstRecursive(sources.get(0))));
      }
      throw new IllegalArgumentException(
          "Unable to remove first node when a node has multiple children, use removeAll instead");
    }
    return node;
  }
Return a list of matching nodes ordered as in pre-order traversal of the plan tree.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/PlanNodeSearcher.java