A fast implementation of kd-tree