private void Relocate(QuadTreeObject <T> item) { // Are we still inside our parent? if (QuadRect.Contains(item.Data.Rect)) { // Good, have we moved inside any of our children? if (childTL != null) { QuadTreeNode <T> dest = GetDestinationTree(item); if (item.Owner != dest) { // Delete the item from this quad and add it to our child // Note: Do NOT clean during this call, it can potentially delete our destination quad QuadTreeNode <T> formerOwner = item.Owner; Delete(item, false); dest.Insert(item); // Clean up ourselves formerOwner.CleanUpwards(); } } } else { // We don't fit here anymore, move up, if we can if (parent != null) { parent.Relocate(item); } } }