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

      IFAState matchedState = null;
      Iterator<IFATransition> transitionIterator;
      IStateMatchInfo stateMatchInfo;
      while (iterator.hasNext()) {
        child = iterator.next();
        IFAState nextScopeState =
            allScope ? null : getNextMatchedScopeState(currentScopeState, child);
        // find first matched state
        if (!preciseMatchTransitionMap.isEmpty()) {
          matchedState = tryGetNextState(child, sourceState, preciseMatchTransitionMap);
        }
        transitionIterator = patternFA.getFuzzyMatchTransitionIterator(sourceState);
        if (matchedState == null) {
          while (transitionIterator.hasNext()) {
            matchedState = tryGetNextState(child, sourceState, transitionIterator.next());
            if (matchedState != null) {
              break;
            }
          }
          if (matchedState == null) {
            releaseNode(child);
            continue;
          }
        }

        // check whether accept the first matched state
        if (mayTargetNodeType(child) && !matchedState.isFinal()) {
          // not accept the first matched state since this node may be a target result, check the
          // other states
          if (patternFA.mayTransitionOverlap() && transitionIterator.hasNext()) {
            stateMatchInfo =
                new StateMultiMatchInfo(
                    patternFA, matchedState, transitionIterator, nextScopeState);
            firstAncestorOfTraceback = ancestorStack.size();

            while (transitionIterator.hasNext()) {
              matchedState = tryGetNextState(child, sourceState, transitionIterator.next());
              if (matchedState != null) {
                stateMatchInfo.addMatchedState(matchedState);
                if (matchedState.isFinal()) {
                  break;
                }
              }
            }
          } else {
            stateMatchInfo = new StateSingleMatchInfo(patternFA, matchedState, nextScopeState);
          }
        } else {
          // accept the first matched state, directly save it
          if (patternFA.mayTransitionOverlap() && transitionIterator.hasNext()) {
            stateMatchInfo =
                new StateMultiMatchInfo(
                    patternFA, matchedState, transitionIterator, nextScopeState);
            firstAncestorOfTraceback = ancestorStack.size();
          } else {
            stateMatchInfo = new StateSingleMatchInfo(patternFA, matchedState, nextScopeState);
          }
        }

        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