@Override
  public R next() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    R result = generateResult(nextMatchedNode);
    if (!shouldVisitSubtree) {
      // release nextMatchedNode
      releaseNode(nextMatchedNode);
    }
    nextMatchedNode = null;
    return result;
  }
This method must be invoked before iteration
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/tree/AbstractTreeVisitor.java