public void FastRemove(object item) { if (ContainedObjects.Contains(item)) { List <OctreeLeaf> toRemove = new List <OctreeLeaf>(); ContainedObjects.Remove(item); foreach (OctreeLeaf leaf in ChildLeaves) { leaf.FastRemove(item); if (leaf.children == null || leaf.children.Count == 0) { toRemove.Add(leaf); } } foreach (OctreeLeaf leaf in toRemove) { ChildLeaves.Remove(leaf); } } }