// ===================================================================
        // TRIGGER PORTS
        // -------------------------------------------------------------------------
        /// Finds the trigger port associated with the givne node.
        ///
        /// @param node Visual script node to serach for a trigger port.
        /// @return The trigger port or _null_ if not found.
        ///
        public static iCS_EditorObject GetTriggerPort(iCS_EditorObject node)
        {
            iCS_EditorObject triggerPort = null;

            node.ForEachChild(p => { if (p.IsTriggerPort)
                                     {
                                         triggerPort = p;
                                     }
                              });
            return(triggerPort);
        }
 // ----------------------------------------------------------------------
 public void ForEachChild(iCS_EditorObject parent, Action <iCS_EditorObject> fnc)
 {
     DetectUndoRedo();
     if (parent == null)
     {
         EditorObjects[0].ForEachChild(child => fnc(child));
     }
     else
     {
         parent.ForEachChild(child => fnc(child));
     }
 }
 // ----------------------------------------------------------------------
 // This function deletes the given object and any associated object
 // to maintain a clean graph without dangling connections, ports, or
 // nodes.
 void ScheduleDestroyInstance(iCS_EditorObject toDestroy)
 {
     if (toDestroy == null || toDestroy.InstanceId == -1)
     {
         return;
     }
     // Don't process if the object has already been processed.
     if (myDestroyQueue.Contains(toDestroy))
     {
         return;
     }
     if (myCachedDestroyQueue.Contains(toDestroy))
     {
         return;
     }
     // Schedule all children to be destroyed first.
     toDestroy.ForEachChild(child => ScheduleDestroyInstance(child));
     // Add the object to the destroy queue.
     if (!myDestroyQueueInUse)
     {
         myDestroyQueue.Add(toDestroy);
     }
     else
     {
         myCachedDestroyQueue.Add(toDestroy);
     }
     // Detroy the transition as a single block.
     if (toDestroy.IsStatePort || toDestroy.IsTransitionPackage || toDestroy.IsTransitionPort)
     {
         iCS_EditorObject outStatePort      = GetFromStatePort(toDestroy);
         iCS_EditorObject inStatePort       = GetInTransitionPort(toDestroy);
         iCS_EditorObject transitionPackage = GetTransitionPackage(toDestroy);
         if (inStatePort != null)
         {
             ScheduleDestroyInstance(inStatePort);
         }
         if (transitionPackage != null)
         {
             ScheduleDestroyInstance(transitionPackage);
         }
         if (outStatePort != null)
         {
             ScheduleDestroyInstance(outStatePort);
         }
     }
 }