kd tree, prepare