public void AddComponent(IProductComponent root, IProductComponent component) { IProductComponent temp = null; bool found = root.FindComponent(component.Name, ref temp); if (found) { if (temp.Type == IProductComponent.ComponentType.product) { temp.Stock += component.Stock; } else if (temp.Type == IProductComponent.ComponentType.productCategory) { Debug.WriteLine("Category already exists, cannot add again"); } } else { ProductComponents.Add(component); } }