optimize the kd-tree plane diving algorithm