private void searchDevicePath(
      PathPatternNode<Void, VoidSerializer> curNode,
      List<String> nodes,
      Set<List<String>> resultNodesSet) {
    nodes.add(curNode.getName());
    if (curNode.isPathPattern()) {
      if (!curNode.getName().equals(IoTDBConstant.MULTI_LEVEL_PATH_WILDCARD)) {
        resultNodesSet.add(
            nodes.size() == 1
                ? new ArrayList<>()
                : new ArrayList<>(nodes.subList(0, nodes.size() - 1)));
      } else {
        // the device of root.sg.d.** is root.sg.d and root.sg.d.**
        if (nodes.size() > 2) {
          resultNodesSet.add(new ArrayList<>(nodes.subList(0, nodes.size() - 1)));
        }
        resultNodesSet.add(new ArrayList<>(nodes));
      }
      if (curNode.isLeaf()) {
        nodes.remove(nodes.size() - 1);
        return;
      }
    }
    for (PathPatternNode<Void, VoidSerializer> childNode : curNode.getChildren().values()) {
      searchDevicePath(childNode, nodes, resultNodesSet);
    }
    nodes.remove(nodes.size() - 1);
  }
Construct tree according to the pathPatternList.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/PathPatternTree.java