From my current understanding of the code (I've not looked at it in detail) squaredDistance could also just be distance, right? And as a comment, we might say that it could also be squaredDistance?
The reason I'm asking is because my KDTreePoint will be a CLLocation, which provides distance(from:), but nothing similar to squared distance.