def get_leaf_queryset(parent_klass, index, filter="pk"):
    def wrapper(*args, **kwargs):
        if type(index) == int:
            arg = args[index]
        else:
            arg = kwargs[index]
            
        parent_qs = parent_klass.objects.filter(**{filter: arg})
        parents = list(parent_qs)
        if parents:
            ids = [p.id for p in parents]
            return parents[0].as_leaf_class().\
                __class__.objects.filter(id__in=ids)
        return parent_qs
    return wrapper
Same as L{get_queryset} but also calls the C{as_leaf_class} function
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/python/expedient/common/permissions/utils.py/get_leaf_queryset