kd tree, last version