protected void enterState(State<TransitionInput> previousState, State<TransitionInput> newState, State<TransitionInput>... submachineStates) {
		// To accommodate submachines and avoid unnecessary callbacks when transitioning states within a submachine,
		// exitCurrentState() only exits currentState (and sets it to null) on this machine if the destination state/
		// path does not include this state, or the destination is this specific state without a nested state.
		// Similarly, this method only (re-)enters the given state if currentState was set to null by exitCurrentState().

		if(currentState==null || !currentState.equals(newState)) {
			for(CompositeState<TransitionInput> composite : determineCompositesBeingEntered(previousState, newState)) {
				enterCompositeState(composite);
			}

			for(StateMachineEventListener<TransitionInput> listener : eventListeners) {
				listener.beforeStateEntered(newState, this);
			}

			newState.onEnter();
			currentState = newState;

			for(StateMachineEventListener<TransitionInput> listener : eventListeners) {
				listener.afterStateEntered(newState, this);
			}
		}

		if(newState instanceof SubmachineState) {
			SubmachineState<TransitionInput> submachineState = (SubmachineState<TransitionInput>)newState;
			initializeSubmachine(submachineState, submachineStates);
		}
	}