The two lines below, one requires dist to be euclidean distance, and the other requires it to be squared distance: https://github.com/stefankoegl/kdtree/blob/master/kdtree.py#L501 https://github.com/stefankoegl/kdtree/blob/master/kdtree.py#L508 And the `best` argument is not used https://github.com/stefankoegl/kdtree/blob/master/kdtree.py#L517