code: def get_groups_to_remove(self, current_roles, roles_to_remove):
          
          current_roles = set(current_roles)
  
          ret = {}
          roles_to_remove = set(roles_to_remove)
          tmp = set([])
          # get sub roles of the role to remove that the user belongs to
          # if we remove a role, there is no reason to keep the sub roles
          for r in roles_to_remove:
              for sr in self._get_subroles(r):
                  if sr not in roles_to_remove and sr in current_roles:
                      tmp.add(sr)
  
          roles_to_remove = roles_to_remove.union(tmp)
          roles = current_roles.difference(set(roles_to_remove))
          groups_roles = self._get_groups(roles)
          groups_roles_to_remove = self._get_groups(roles_to_remove)
  
          # if groups belongs to roles the user keeps, don't remove it
          for b in groups_roles_to_remove:
              if b in groups_roles:
                  groups_roles_to_remove[b] = \
                      groups_roles_to_remove[b].difference(groups_roles[b])
          return groups_roles_to_remove
docs: get groups to remove from list of
          roles to remove and current roles