ef METHOD_NAME(album):
    # Populate parent+subalbums list
    sa_ids=[a.id]
    for sa in a.subalbums.filter(atype__in=[Album.CURATED, Album.PERSON]):
       sa_ids.append(sa.id)
    # Get photos
    qs = Photo.objects.filter(rephoto_of__isnull=True).prefetch_related('albumphoto').filter(albumphoto__album__in=sa_ids)
    return qs.distinct('id').only('id').order_by()