static void removeObject(GeometricObject go) { if (go is Compound) { Compound com = (Compound)go; foreach (GeometricObject g in com.Objects) { removeObject(g); } } GeometricObject.Remove(go.Name); }