def iter_blocks(course):
 def visit(block):
  ' get child blocks '
  (yield block)
  for child in block.get_children():
   for descendant in visit(child):
    (yield descendant)
 return visit(course)

def iter_blocks ( course ) : def visit ( block ) : ( yield block ) for child in block . get_children ( ) : for descendant in visit ( child ) : ( yield descendant ) return visit ( course )
returns an iterator over all of the blocks in a course .