/// <summary>
        ///     Returns the update of the enclosing state in the dictionary.
        ///     If it cannot be found, it is created.
        /// </summary>
        /// <param name="dictionary"></param>
        /// <returns></returns>
        private State EnclosingStateUpdate(Dictionary dictionary)
        {
            State retVal = null;

            if (EnclosingState != null && dictionary.Updates == Dictionary)
            {
                State updatedState = dictionary.FindByFullName(EnclosingState.FullName) as State;
                if (updatedState == null)
                {
                    retVal = EnclosingState.CreateStateUpdate(dictionary);
                }
            }

            return retVal;
        }
        /// <summary>
        ///     Provides the update of the state machine enclosing a rule or state.
        /// </summary>
        /// <param name="dictionary"></param>
        /// <returns></returns>
        public StateMachine CreateSubStateMachineUpdate(Dictionary dictionary)
        {
            StateMachine retVal = null;
            if (this != FindTopLevelStateMachine())
            {
                State refState = EnclosingStateUpdate(dictionary);
                retVal = refState.StateMachine;
            }
            else
            {
                StateMachine updateSm = dictionary.FindByFullName(FullName) as StateMachine;
                if (updateSm == null)
                {
                    // If the element does not already exist in the patch, add a copy to it
                    updateSm = CreateStateMachineUpdate(dictionary);
                }

                retVal = updateSm;
            }

            return retVal;
        }