public void RemoveState(int state) { foreach (var node in states[state].containedNodes) { RemoveState(node); } if (states[state].parent >= 0) { states[states[state].parent].containedNodes.Remove(state); } transitions.RemoveAll((t) => t.source == state || t.target == state); states.Remove(state); }