def select_related_descend(field, restricted, requested, reverse=False):
    if not field.rel:
        return False
    if field.rel.parent_link and not reverse:
        return False
    if restricted:
        if reverse and field.related_query_name() not in requested:
            return False
        if not reverse and field.name not in requested:
            return False
    if not restricted and field.null:
        return False
    return True

# This function is needed because data descriptors must be defined on a class
# object, not an instance, to have any effect.
Returns True if this field should be used to descend deeper for
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.4/django/db/models/query_utils.py/select_related_descend