code: public void collectPermissionNodes(AccessControlGroup group, Set<AccessControl> permissions) {
  
      boolean added = permissions.add(group);
      if (!added) {
        // we have already visited this node, stop recursion...
        return;
      }
      for (AccessControlPermission permission : group.getPermissions()) {
        permissions.add(permission);
      }
      for (AccessControlGroup inheritedGroup : group.getInherits()) {
        collectPermissionNodes(inheritedGroup, permissions);
      }
    }
docs: Recursive implementation of {@link #collectAccessControls(String, Set)} for {@link AccessControlGroup}s.
  
  @param group is the {@link AccessControlGroup} to traverse.
  @param permissions is the {@link Set} used to collect.