public void OnClickRemoveNode(Node node) { var connectionsToRemove = new List <ConnectionPoint>(); var behaviourNodeGuid = node.BehaviourNode.Guid; foreach (var compoundNode in _nodes.Values.OfType <CompoundNode>()) { var compound = compoundNode.BehaviourNode; for (int i = 0; i < compound.GetChildCount(); i++) { if (compound.GetChildAt(i) == behaviourNodeGuid) { compound.SetChild(i, null); connectionsToRemove.Add(compoundNode.OutPoints[i]); } } } foreach (var connectionPoint in connectionsToRemove) { OnClickRemoveConnectionPoint(connectionPoint); } _nodes.Remove(node.BehaviourNode.Guid); _nodeCount--; _target.RemoveBehaviour(node.BehaviourNode); }