code: public Set<Group> findGroups(final User user, final boolean inheritOnly)
      {
          final Set<Group> result = new HashSet<Group>();
          List<Group> stack;
          
          // Recursively find user groups
          for(final Group group : this.getRootGroups())
          {
              stack = new ArrayList<Group>();
              this.addGroups(user, result, group, stack, inheritOnly);
          }
          
          return result;
      }
docs: Finds the set of groups where a given user is a member.
  
  @param user
  The member user.
  @param inheritOnly
  Indicates if only the ancestors groups that have their "inheritRoles" property
  enabled should be added.
  @return The set of groups.