def get_block_dict(top_level_block):
block_stack = [top_level_block]<EOL>block_dict = {}<EOL>while block_stack:<EOL><INDENT>block = block_stack.pop()<EOL>block_dict[block.name] = str(block)<EOL>for segment in block.segments:<EOL><INDENT>if isinstance(segment, Block):<EOL><INDENT>block_stack.append(segment)<EOL><DEDENT><DEDENT><DEDENT>return block_dict<EOL>
Returns a dictionary of block names (str) to block contents (str) for all child blocks, as
    well as the original block itself.

    The block_dict argument is only used for recursive calls and should not