private void DrawNode(IAINode node)
        {
            var  rect        = EditorGUILayout.GetControlRect();
            bool hasChildren = (node is IAIActionGroup || node is IAIStateMachine);

            //first click region
            if (MouseUtil.GuiClicked(Event.current, MouseUtil.BTN_LEFT, rect))
            {
                _currentSelectionId = AITreeDebugWindow.GetNodeHash(node);
                if (node is Component)
                {
                    Selection.activeGameObject = (node as Component).gameObject;
                    EditorGUIUtility.PingObject(node as Component);
                }
                this.Repaint();
            }
            else if (MouseUtil.GuiClicked(Event.current, MouseUtil.BTN_RIGHT, rect))
            {
                this.DrawPopup(node);
            }

            //draw selection rect
            if (_currentSelectionId == AITreeDebugWindow.GetNodeHash(node))
            {
                EditorGUI.DrawRect(rect, _selectedColor);
            }

            //draw label
            if (hasChildren)
            {
                _currentTable[node] = EditorGUI.Foldout(rect, _currentTable[node], node.DisplayName);
            }
            else
            {
                EditorGUI.LabelField(rect, node.DisplayName);
            }

            //highlight if running
            if (node is IAIAction)
            {
                var act = node as IAIAction;
                switch (act.ActionState)
                {
                case ActionResult.Waiting:
                    EditorGUI.DrawRect(rect, _waitingColor);
                    break;

                case ActionResult.Success:
                    EditorGUI.DrawRect(rect, _successColor);
                    break;

                case ActionResult.Failed:
                    EditorGUI.DrawRect(rect, _failedColor);
                    break;
                }
            }
            else if (node is IAIState)
            {
                var state = node as IAIState;
                if (state.IsActive)
                {
                    EditorGUI.DrawRect(rect, _activeStateColor);
                }
            }


            if (hasChildren && _currentTable[node])
            {
                EditorGUI.indentLevel++;
                if (node is IAIActionGroup)
                {
                    foreach (var child in (node as IAIActionGroup))
                    {
                        this.DrawNode(child);
                    }
                }
                else if (node is IAIStateMachine)
                {
                    foreach (var child in (node as IAIStateMachine))
                    {
                        this.DrawNode(child);
                    }
                }
                EditorGUI.indentLevel--;
            }
        }