public override void RemoveChild(TValue value) { int index; var nodeToRemove = root.GetNode(value); var removed = false; while ((index = ChildrenList.IndexOf(nodeToRemove)) != -1) { ChildrenList.RemoveAt(index); ConnectionWays.RemoveAt(index); removed = true; } if (!removed) { throw new InvalidOperationException(string.Format("Node '{0}' does not have child '{1}'.", Value, value)); } root.GarbageCollect(); }