docs: private void addGroups(final User user, final Set<Group> userGroups, final Group currentGroup,
              final List<Group> stack, final boolean inheritOnly)
      {
          if((currentGroup != null) && !stack.contains(currentGroup))
          {
              stack.add(currentGroup);
              
              if(currentGroup.getMemberUsers().contains(user))
              {
                  userGroups.add(currentGroup);
                  
                  // Add the ancestor groups as well
                  boolean inherit = !inheritOnly || currentGroup.isInheritingRoles();
                  Group group;
                  
                  for(int i = stack.size() - 2; inherit && (i >= 0); i--)
                  {
                      group = stack.get(i);
                      userGroups.add(group);
                      inherit = !inheritOnly || group.isInheritingRoles();
                  }
              }
              
              for(final Group group : currentGroup.getMemberGroups())
              {
                  this.addGroups(user, userGroups, group, stack, inheritOnly);
              }
          }
      }