private PlanNode replaceFirstRecursive(PlanNode node, PlanNode nodeToReplace) {
    node = lookup.resolve(node);

    if (where.test(node)) {
      return nodeToReplace;
    }
    List<PlanNode> sources = node.getChildren();
    if (sources.isEmpty()) {
      return node;
    }
    if (sources.size() == 1) {
      return replaceChildren(node, ImmutableList.of(replaceFirstRecursive(node, sources.get(0))));
    }
    throw new IllegalArgumentException(
        "Unable to replace first node when a node has multiple children, use replaceAll instead");
  }
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