private GroupWithPermissionQueryResult toGroupQueryResult(List<GroupWithPermissionDto> dtos, PermissionQuery query) {
addAnyoneGroup(dtos, query);
List<GroupWithPermissionDto> filteredDtos = filterMembership(dtos, query);
Paging paging = Paging.create(query.pageSize(), query.pageIndex(), filteredDtos.size());
List<GroupWithPermission> pagedGroups = pagedGroups(filteredDtos, paging);
return new GroupWithPermissionQueryResult(pagedGroups, paging.hasNextPage());
}