code: protected void collectAccessControls(AccessControlGroup group, Set<AccessControlGroup> toplevelGroups) {
  
      if (!toplevelGroups.contains(group)) {
        throw new IllegalStateException("Invalid group not declared as top-level group in schema: " + group);
      }
      AccessControl old = this.id2nodeMap.put(group.getId(), group);
      if (old != null) {
        LOG.debug("Already visited access control group {}", group);
        if (old != group) {
          throw new IllegalStateException(
              "Invalid security configuration: duplicate groups with id " + group.getId() + "!");
        }
        // group has already been visited, stop recursion...
        return;
      } else {
        LOG.debug("Registered access control group {}", group);
      }
      for (AccessControlPermission permission : group.getPermissions()) {
        old = this.id2nodeMap.put(permission.getId(), permission);
        if (old != null) {
          // throw new IllegalStateException("Invalid security configuration: duplicate permission with id "
          // + permission.getId() + "!");
          LOG.warn("Security configuration contains duplicate permission with id {}.", permission.getId());
        } else {
          LOG.debug("Registered access control permission {}", permission);
        }
      }
      for (AccessControlGroup inheritedGroup : group.getInherits()) {
        collectAccessControls(inheritedGroup, toplevelGroups);
      }
    }
docs: Called from {@link #initialize(AccessControlSchema)} to collect all {@link AccessControl}s recursively.
  
  @param group the {@link AccessControlGroup} to traverse.
  @param toplevelGroups is the {@link Set} of all {@link AccessControlGroup}s from
  {@link AccessControlSchema#getGroups()}.