There are n nodes (rectangles), and the center point of its i-th node is represented as (xi, yi). A parent node has at most r child nodes.
- Sort all nodes according to x.
- Divide all nodes into sqrt (n/r) parts, each of which is sorted by y.
- Every r nodes are merged into a new parent node.
- Repeat (1)~(3) until the number of parent nodes is 1.