handling check for scipy version and support for older KDTree