Take a list (block) or string (statement) and flattens it into a string
    with indentation.

def flatten_blocks(lines, num_indents=-1):
    """
    Take a list (block) or string (statement) and flattens it into a string
    with indentation.
    """
    # The standard indent is four spaces
    INDENTATION = " " * 4

    if not lines:
        return ""

    # If this is a string, add the indentation and finish here
    if isinstance(lines, six.string_types):
        return INDENTATION * num_indents + lines

    # If this is not a string, join the lines and recurse
    return "\n".join([flatten_blocks(line, num_indents + 1) for line in lines])