private void traceback(
        N node,
        IStateMatchInfo stateMatchInfo,
        int checkedSourceStateOrdinal,
        boolean needFinalState) {
      IStateMatchInfo parentStateMatchInfo;

      N currentNode;
      IStateMatchInfo currentStateMatchInfo;

      int sourceStateOrdinal;
      IFAState sourceState = null;
      Iterator<IFATransition> transitionIterator = null;

      int matchedStateSize;
      IFAState matchedState;

      int currentNodeIndex;
      for (int i = ancestorStack.size() - 1; i >= firstAncestorOfTraceback; i--) {
        parentStateMatchInfo = ancestorStack.get(i - 1).stateMatchInfo;
        currentStateMatchInfo = ancestorStack.get(i).stateMatchInfo;

        // there's no state not further searched
        if (currentStateMatchInfo.getSourceStateOrdinal()
            == parentStateMatchInfo.getMatchedStateSize()) {
          continue;
        }

        // there's some state not further searched, process them in order
        currentNodeIndex = i;
        while (currentNodeIndex >= i) {
          parentStateMatchInfo = ancestorStack.get(currentNodeIndex - 1).stateMatchInfo;

          if (currentNodeIndex == ancestorStack.size()) {
            currentNode = node;
            currentStateMatchInfo = stateMatchInfo;
          } else {
            currentNode = ancestorStack.get(currentNodeIndex).node;
            currentStateMatchInfo = ancestorStack.get(currentNodeIndex).stateMatchInfo;
          }

          matchedState = null;
          if (currentNode == node) {
            sourceStateOrdinal = checkedSourceStateOrdinal;
          } else {
            sourceStateOrdinal = currentStateMatchInfo.getSourceStateOrdinal();
            if (sourceStateOrdinal == parentStateMatchInfo.getMatchedStateSize()) {
              currentNodeIndex--;
              continue;
            }
            // there may be some states could be matched from transition of current source state
            sourceState = parentStateMatchInfo.getMatchedState(sourceStateOrdinal);
            transitionIterator = currentStateMatchInfo.getSourceTransitionIterator();
            while (transitionIterator.hasNext()) {
              matchedState = tryGetNextState(currentNode, sourceState, transitionIterator.next());
              if (matchedState != null) {
                break;
              }
            }
          }

          if (matchedState == null) {
            while (++sourceStateOrdinal < parentStateMatchInfo.getMatchedStateSize()) {
              sourceState = parentStateMatchInfo.getMatchedState(sourceStateOrdinal);
              matchedStateSize = currentStateMatchInfo.getMatchedStateSize();
              transitionIterator =
                  tryGetNextMatchedState(
                      currentNode, sourceState, currentStateMatchInfo, needFinalState);
              // change of matchedStateSize means currentNode there is transition from sourceState
              // matching currentNode
              if (matchedStateSize != currentStateMatchInfo.getMatchedStateSize()) {
                matchedState = currentStateMatchInfo.getMatchedState(matchedStateSize);
                currentStateMatchInfo.setSourceStateOrdinal(sourceStateOrdinal);
                currentStateMatchInfo.setSourceTransitionIterator(transitionIterator);
                break;
              }
            }
            if (matchedState == null) {
              currentStateMatchInfo.setSourceStateOrdinal(sourceStateOrdinal - 1);
              currentStateMatchInfo.setSourceTransitionIterator(transitionIterator);
              currentNodeIndex--;
              continue;
            }
          }

          currentStateMatchInfo.addMatchedState(matchedState);

          if (currentNode == node) {
            if (needFinalState && !currentStateMatchInfo.hasFinalState()) {
              while (transitionIterator.hasNext()) {
                matchedState = tryGetNextState(currentNode, sourceState, transitionIterator.next());
                if (matchedState != null) {
                  currentStateMatchInfo.addMatchedState(matchedState);
                  if (matchedState.isFinal()) {
                    return;
                  }
                }
              }
              currentNodeIndex--;
            } else {
              return;
            }
          } else {
            currentNodeIndex++;
          }
        }
      }
    }
Try to get next matched state from sourceState and add it into currentStateMatchInfo

@param child child node to match
@param sourceState source state
@param currentStateMatchInfo currentStateMatchInfo
@return iterator of rest transitions
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/tree/AbstractTreeVisitor.java