Working kd-tree