Fix memory leak in KD-tree.