'Add all descendants of `descriptor` to this FieldDataCache.
Arguments:
descriptor: An XModuleDescriptor
depth is the number of levels of descendant modules to load StudentModules for, in addition to
the supplied descriptor. If depth is None, load all descendant StudentModules
descriptor_filter is a function that accepts a descriptor and return whether the field data
should be cached'

def add_descriptor_descendents(self, descriptor, depth=None, descriptor_filter=(lambda descriptor: True)):

    def get_child_descriptors(descriptor, depth, descriptor_filter):
        '\n                                                Return    a    list    of    all    child    descriptors    down    to    the    specified    depth\n                                                that    match    the    descriptor    filter.    Includes    `descriptor`\n\n                                                descriptor:    The    parent    to    search    inside\n                                                depth:    The    number    of    levels    to    descend,    or    None    for    infinite    depth\n                                                descriptor_filter(descriptor):    A    function    that    returns    True\n                                                                if    descriptor    should    be    included    in    the    results\n                                                '
        if descriptor_filter(descriptor):
            descriptors = [descriptor]
        else:
            descriptors = []
        if ((depth is None) or (depth > 0)):
            new_depth = ((depth - 1) if (depth is not None) else depth)
            for child in (descriptor.get_children() + descriptor.get_required_module_descriptors()):
                descriptors.extend(get_child_descriptors(child, new_depth, descriptor_filter))
        return descriptors
    with modulestore().bulk_operations(descriptor.location.course_key):
        descriptors = get_child_descriptors(descriptor, depth, descriptor_filter)
    self.add_descriptors_to_cache(descriptors)
