private void checkAndDeleteStateAlongTraversedPath()

in src/main/software/amazon/event/ruler/ByteMachine.java [431:459]


    private void checkAndDeleteStateAlongTraversedPath(
            ArrayDeque<AbstractMap.SimpleImmutableEntry<Byte, ByteTransition>> byteStateQueue) {

        if (byteStateQueue.isEmpty()) {
            return;
        }

        Byte childByteKey = byteStateQueue.pollFirst().getKey();
        while (!byteStateQueue.isEmpty()) {
            final AbstractMap.SimpleImmutableEntry<Byte, ByteTransition> parentStatePair = byteStateQueue.pollFirst();
            final Byte parentByteKey = parentStatePair.getKey();
            final ByteTransition parentByteTransition = parentStatePair.getValue();
            for (SingleByteTransition singleParent : parentByteTransition.expand()) {

                // Check all transitions from singleParent using childByteKey. Delete each transition that is a dead-end
                // (i.e. transition that has no transitions itself).
                ByteTransition transition = getTransition(singleParent, childByteKey);
                for (SingleByteTransition eachTrans : transition.expand()) {
                    ByteState nextState = eachTrans.getNextByteState();
                    if (nextState != null && nextState.hasNoTransitions()) {
                        putTransitionNextState(singleParent.getNextByteState(), getParser().parse(childByteKey),
                                eachTrans, null);
                    }
                }

            }
            childByteKey = parentByteKey;
        }
    }