'Returns the list of all children ids for a given directory id recursively, excluding history documents'

def _get_child_ids_recursively(self, directory_id):

    directory = Directory.objects.get(id=directory_id)
    children_ids = []
    for child in directory.children.filter(is_history=False).filter(is_managed=False):
        children_ids.append(child.id)
        if child.is_directory:
            children_ids.extend(self._get_child_ids_recursively(child.id))
    return children_ids
