@Override public List<EPerson> allMembers(Context c, Group g) throws SQLException { // two queries - first to get all groups which are a member of this group // second query gets all members of each group in the first query // Get all groups which are a member of this group List<Group2GroupCache> group2GroupCaches = group2GroupCacheDAO.findByParent(c, g); Set<Group> groups = new HashSet<>(); for (Group2GroupCache group2GroupCache : group2GroupCaches) { groups.add(group2GroupCache.getChild()); } Set<EPerson> childGroupChildren = new HashSet<>(ePersonService.findByGroups(c, groups)); //Don't forget to add our direct children childGroupChildren.addAll(g.getMembers()); return new ArrayList<>(childGroupChildren); }