kdtree and octree sample code