public CoverNode <T> AddRectangle(SpatialObj <T> rect, bool reorganize = true) { CoverNode <T> deepest_field = FindContainingField(rect, rootNode); if (deepest_field.IsFull() && !deepest_field.HasChildren()) { PartitionField(deepest_field); CoverNode <T> node = AddRectangle(rect); if (reorganize) { ReorganizeOverflownNodes(); } if (node != null) { return(node); } } else { bool overflown = deepest_field.StoreRectangle(rect); } if (deepest_field != null) { Count += 1; } return(deepest_field); }