Implementing Approximate Nearest Neighbor Search with KD-Trees