factored out scipy KDTree for more efficient foreign neighbors search