rebalance method
void
rebalance()
Rebalances the tree by rebuilding its structure
Implementation
void rebalance() {
if (isLeaf) return;
// Collect all particles from subtree
final allParticles = getAllParticles();
// Clear current structure
clear();
// Rebuild with optimal structure
for (final QuadTreeParticle particle in allParticles) {
insert(particle);
}
}