private void Output_OnInputRemoved(NodeOutput inp) { var empties = Outputs.FindAll(m => m.To.Count == 0); if (Outputs.Count > 2 && empties != null && empties.Count >= 2) { var inp2 = empties[empties.Count - 1]; inp2.OnInputAdded -= Output_OnInputAdded; inp2.OnInputRemoved -= Output_OnInputRemoved; Outputs.Remove(inp2); RemovedOutput(inp2); } }