Generate kdtree and serialize it to disk