public ClusterSchemaTree fetchDeviceSchema(
      PathPatternTree patternTree, PathPatternTree authorityScope) throws MetadataException {
    ClusterSchemaTree schemaTree = new ClusterSchemaTree();
    for (PartialPath pattern : patternTree.getAllPathPatterns()) {
      try (EntityCollector<Void, ICachedMNode> collector =
          new EntityCollector<Void, ICachedMNode>(rootNode, pattern, store, false, authorityScope) {
            @Override
            protected Void collectEntity(IDeviceMNode<ICachedMNode> node) {
              if (node.isAlignedNullable() != null) {
                schemaTree.appendTemplateDevice(
                    node.getPartialPath(), node.isAligned(), node.getSchemaTemplateId(), null);
              }
              return null;
            }
          }) {
        collector.traverse();
      }
    }
    return schemaTree;
  }
Check if the device node exists

@param deviceId full path of device
@return true if the device node exists
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/MTreeBelowSGCachedImpl.java