Add a vec_perm_indices_to_tree helper function