Performs fast lookups of nearest neighbors using the Ball Tree algorithm for space partitioning
Note that this code borrows heavily from
Bounded priority queue.
Bounded priority queue. This class wraps the original PriorityQueue
class and modifies it such that only the top K elements are retained.
The top K elements are defined by an implicit Ordering[A].