Made KDTree parametric