public static <V, T extends PathPatternNode.Serializer<V>> PathPatternNode<V, T> deserializeNode(
      final ByteBuffer buffer, final T serializer, final Consumer<String> nodeNameProcessor) {
    final PathPatternNode<V, T> node =
        new PathPatternNode<>(ReadWriteIOUtils.readString(buffer), serializer);
    nodeNameProcessor.accept(node.name);
    final int typeOrValueSize = ReadWriteIOUtils.readInt(buffer);
    if (typeOrValueSize >= 0) {
      // measurement node in PatternTreeMap
      final Set<V> valueSet = new HashSet<>();
      for (int i = 0; i < typeOrValueSize; i++) {
        valueSet.add(serializer.read(buffer));
      }
      node.valueSet = valueSet;
    } else if (typeOrValueSize == -1) {
      // node in PathPatternTree
      node.markPathPattern(true);
    }
    int childrenSize = ReadWriteIOUtils.readInt(buffer);
    while (childrenSize > 0) {
      final PathPatternNode<V, T> tmpNode = deserializeNode(buffer, serializer, nodeNameProcessor);
      node.addChild(tmpNode);
      childrenSize--;
    }
    return node;
  }
Serialize PathPatternNode

<ul>
  <li>[required] 1 string: name. It specifies the name of node
  <li>[required] 1 int: nodeType or size of valueSet.
      <ul>
        <li>If this node is being used by PathPatternTree, it specifies the type of this node.
            -1 means from root to the current node is a registered path pattern. Otherwise -2.
        <li>If this node is being used by PatternTreeMap, it specifies the size of valueSet
            which will be serialized next.(>=0)
      </ul>
  <li>[optional] valueSet
  <li>[required] 1 int: children size.
  <li>[optional] children
</ul>
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/PathPatternNode.java