Custom KDTree implementation with efficient method for 'Foreign Nearest Neighbor Search'