code: def get_roles(self, groups):
          
          roles = set([])
          parentroles = set([])
          notroles = set([])
          tmp = set([])
          usedgroups = {}
          unusedgroups = {}
          ret = {}
          # determine roles membership
          for role in self.roles:
              if self._check_member(
                      role, groups, notroles,
                      tmp, parentroles, usedgroups):
                  roles.add(role)
          # determine standalone groups not matching any roles
          for b in groups:
              for g in groups[b]:
                  if b not in usedgroups or g not in usedgroups[b]:
                      if b not in unusedgroups:
                          unusedgroups[b] = set([])
                      unusedgroups[b].add(g)
  
          ret['roles'] = roles
          ret['unusedgroups'] = unusedgroups
          return ret
docs: get list of roles and list of standalone groups