code draft for KdTree