public Transition<ET, ?> nextChainedTransition(State<ET> inputState, Event<?> event,
            ET entity) throws FiniteStateException
    {
        if (!initialized)
            throw new FiniteStateException(
                    "State map not yet initialized through call to build() method");

        State matchingState = inputState;
        boolean noMatcher = true;
        Transition<ET, ?> transition = null;

        // Walk the state hierarchy looking for a transition that accepts this
        // event.
        while (matchingState != null)
        {
            TransitionMatcher<ET> matcher = transitionMap.get(matchingState);
            if (matcher != null)
            {
                noMatcher = false;
                transition = matcher.matchTransition(event, entity);
                if (transition != null)
                    break;
            }
            matchingState = matchingState.getParent();
        }

        // Could not find any transitions from this state.
        if (noMatcher)
        {
            throw new TransitionNotFoundException(
                    "No exit transitions from state", inputState, event, entity);
        }

        if (transition == null)
        {
            throw new TransitionNotFoundException(
                    "No matching exit transition found", inputState, event,
                    entity);
        }
        return transition;
    }