@Override
    protected void getNext() throws Exception {
      if (iterator == null) {
        this.iterator = initChildrenIterator();
      }
      N child;

      IFAState sourceState;

      IStateMatchInfo stateMatchInfo;
      Iterator<IFATransition> transitionIterator;

      while (iterator.hasNext()) {

        child = iterator.next();
        IFAState nextScopeState =
            allScope ? null : getNextMatchedScopeState(currentScopeState, child);

        stateMatchInfo = new StateMultiMatchInfo(patternFA, nextScopeState);
        if (mayTargetNodeType(child)) {
          for (int i = 0; i < sourceStateMatchInfo.getMatchedStateSize(); i++) {
            sourceState = sourceStateMatchInfo.getMatchedState(i);
            transitionIterator = tryGetNextMatchedState(child, sourceState, stateMatchInfo, true);
            if (stateMatchInfo.getMatchedStateSize() > 0) {
              stateMatchInfo.setSourceStateOrdinal(i);
              stateMatchInfo.setSourceTransitionIterator(transitionIterator);
              if (stateMatchInfo.hasFinalState()) {
                break;
              }
            }
          }

          if (stateMatchInfo.getMatchedStateSize() == 0 || !stateMatchInfo.hasFinalState()) {
            traceback(child, stateMatchInfo, sourceStateMatchInfo.getMatchedStateSize() - 1, true);
            if (stateMatchInfo.getMatchedStateSize() == 0) {
              releaseNode(child);
              continue;
            }
          }
        } else {
          for (int i = 0; i < sourceStateMatchInfo.getMatchedStateSize(); i++) {
            sourceState = sourceStateMatchInfo.getMatchedState(i);
            transitionIterator = tryGetNextMatchedState(child, sourceState, stateMatchInfo, false);
            if (stateMatchInfo.getMatchedStateSize() > 0) {
              stateMatchInfo.setSourceStateOrdinal(i);
              stateMatchInfo.setSourceTransitionIterator(transitionIterator);
              break;
            }
          }

          if (stateMatchInfo.getMatchedStateSize() == 0) {
            traceback(child, stateMatchInfo, sourceStateMatchInfo.getMatchedStateSize() - 1, false);
            if (stateMatchInfo.getMatchedStateSize() == 0) {
              releaseNode(child);
              continue;
            }
          }
        }

        saveResult(child, stateMatchInfo);
        return;
      }
    }
The method used for generating the result based on the matched node.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/tree/AbstractTreeVisitor.java