Porting KdTree ( https://github.com/ubilabs/kd-tree-javascript )