buildKDTreeV4 is the final version 

buildKDTree is the final version of the building function
advanced kd-tree scheme implemented