'Traverses all the blocks in the given course.
If access_all_block_fields is True, also reads all the
xblock fields in each block in the course.'

def _traverse_blocks_in_course(self, course, access_all_block_fields):

    all_blocks = []
    stack = [course]
    while stack:
        curr_block = stack.pop()
        all_blocks.append(curr_block)
        if curr_block.has_children:
            for block in reversed(curr_block.get_children()):
                stack.append(block)
    if access_all_block_fields:
        for xblock in all_blocks:
            for (__, field) in xblock.fields.iteritems():
                if field.is_set_on(xblock):
                    __ = field.read_from(xblock)
