kd-tree nearest-neighbor implemented