Implementing KDTree search for 1-NN search