code: public Set<CmsGroup> getRoleGroupsImpl(
          CmsDbContext dbc,
          String roleGroupName,
          boolean directUsersOnly,
          Map<String, Set<CmsGroup>> accumulator)
      throws CmsException {
  
          Set<CmsGroup> result = new HashSet<CmsGroup>();
          if (accumulator.get(roleGroupName) != null) {
              return accumulator.get(roleGroupName);
          }
          CmsGroup group = readGroup(dbc, roleGroupName); // check that the group really exists
          if ((group == null) || (!group.isRole())) {
              throw new CmsDbEntryNotFoundException(
                  Messages.get().container(Messages.ERR_UNKNOWN_GROUP_1, roleGroupName));
          }
          result.add(group);
          if (!directUsersOnly) {
              CmsRole role = CmsRole.valueOf(group);
              if (role.getParentRole() != null) {
                  try {
                      String parentGroup = role.getParentRole().getGroupName();
                      // iterate the parent roles
                      result.addAll(getRoleGroupsImpl(dbc, parentGroup, directUsersOnly, accumulator));
                  } catch (CmsDbEntryNotFoundException e) {
                      // ignore, this may happen while deleting an orgunit
                      if (LOG.isDebugEnabled()) {
                          LOG.debug(e.getLocalizedMessage(), e);
                      }
                  }
              }
              String parentOu = CmsOrganizationalUnit.getParentFqn(group.getOuFqn());
              if (parentOu != null) {
                  // iterate the parent ou's
                  result.addAll(getRoleGroupsImpl(dbc, parentOu + group.getSimpleName(), directUsersOnly, accumulator));
              }
          }
          accumulator.put(roleGroupName, result);
          return result;
      }
docs: Collects the groups which constitute a given role.<p>
  
  @param dbc the database context
  @param roleGroupName the group related to the role
  @param directUsersOnly if true, only the group belonging to the entry itself wil
  @param accumulator a map for memoizing return values of recursive calls
  
  @return the set of groups which constitute the role
  
  @throws CmsException if something goes wrong