code: private Collection<Group> findGroups(Session session, Group parent, boolean recursive) throws Exception
     {
        List<Group> groups = new ArrayList<Group>();
        String parentId = parent == null ? "" : parent.getId();
  
        NodeIterator childNodes = utils.getGroupNode(session, parentId).getNodes();
  
        while (childNodes.hasNext())
        {
           Node groupNode = childNodes.nextNode();
           if (!groupNode.getName().startsWith(JCROrganizationServiceImpl.JOS_MEMBERSHIP))
           {
              Group group = readGroup(groupNode);
              groups.add(group);
  
              if (recursive)
              {
                 groups.addAll(findGroups(session, group, recursive));
              }
           }
        }
  
        return groups;
     }
docs: Find children groups. Parent group is not included in result.
  
  @param recursive
  if true, the search should be recursive. It means go down to the tree
  until bottom will reach