def _dict_org(request, organizations):
    orgs = []
    for o in organizations:
        # We don't wish to double count sub organization memberships.
        owners = [
            {
                'first_name': ou.user.first_name,
                'last_name': ou.user.last_name,
                'email': ou.user.email,
                'id': ou.user.pk
            }
            for ou in OrganizationUser.objects.filter(
                organization=o, role_level=ROLE_OWNER
            )
        ]
        if OrganizationUser.objects.filter(
            organization=o, user=request.user
        ).exists():
            ou = OrganizationUser.objects.get(
                organization=o, user=request.user)
            role_level = _get_js_role(ou.role_level)
        else:
            role_level = None
        org = {
            'name': o.name,
            'org_id': o.pk,
            'id': o.pk,
            'number_of_users': o.users.count(),
            'user_is_owner': (
                request.user.pk in [own['id'] for own in owners]
            ),
            'user_role': role_level,
            'owners': owners,
            'sub_orgs': _dict_org(request, o.child_orgs.all()),
            'is_parent': o.is_parent,
            'num_buildings': CanonicalBuilding.objects.filter(
                canonical_snapshot__super_organization=o
            ).count(),
        }
        orgs.append(org)

    return orgs
returns a dictionary of an organization's data.
dataset/ETHPy150Open buildingenergy/buildingenergy-platform/seed/views/accounts.py/_dict_org