[core] kd-tree part 3 (not final)