[core] Fix of memory leak in KD-Tree