code: private List<CmsGroup> getVirtualGroupsForRole(CmsDbContext dbc, CmsRole role) throws CmsException {
  
          Set<Integer> roleFlags = new HashSet<Integer>();
          // add role flag
          Integer flags = new Integer(role.getVirtualGroupFlags());
          roleFlags.add(flags);
          // collect all child role flags
          Iterator<CmsRole> itChildRoles = role.getChildren(true).iterator();
          while (itChildRoles.hasNext()) {
              CmsRole child = itChildRoles.next();
              flags = new Integer(child.getVirtualGroupFlags());
              roleFlags.add(flags);
          }
          // iterate all groups matching the flags
          List<CmsGroup> groups = new ArrayList<CmsGroup>();
          Iterator<CmsGroup> it = getGroups(dbc, readOrganizationalUnit(dbc, role.getOuFqn()), false, false).iterator();
          while (it.hasNext()) {
              CmsGroup group = it.next();
              if (group.isVirtual()) {
                  CmsRole r = CmsRole.valueOf(group);
                  if (roleFlags.contains(new Integer(r.getVirtualGroupFlags()))) {
                      groups.add(group);
                  }
              }
          }
          return groups;
      }
docs: Returns all groups that are virtualizing the given role in the given ou.<p>
  
  @param dbc the database context
  @param role the role
  
  @return all groups that are virtualizing the given role (or a child of it)
  
  @throws CmsException if something goes wrong