Fix set_perm_recursive() implementation