'Returns the path from the last module visited by the current user in the given course up to
the course module. If there is no such visit, the first item deep enough down the course
tree is used.'

def _last_visited_module_path(self, request, course):

    field_data_cache = FieldDataCache.cache_for_descriptor_descendents(course.id, request.user, course, depth=2)
    course_module = get_module_for_descriptor(request.user, request, course, field_data_cache, course.id, course=course)
    path = [course_module]
    chapter = get_current_child(course_module, min_depth=2)
    if (chapter is not None):
        path.append(chapter)
        section = get_current_child(chapter, min_depth=1)
        if (section is not None):
            path.append(section)
    path.reverse()
    return path
