def get_ast(token):
    """
    Recursively unrolls token attributes into dictionaries (token.children
    into lists).

    Returns:
        a dictionary of token's attributes.
    """
    node = {}
    # Python 3.6 uses [ordered dicts] [1].
    # Put in 'type' entry first to make the final tree format somewhat
    # similar to [MDAST] [2].
    #
    #   [1]: https://docs.python.org/3/whatsnew/3.6.html
    #   [2]: https://github.com/syntax-tree/mdast
    node['type'] = token.__class__.__name__
    node.update({key: token.__dict__[key] for key in token.__dict__})
    if 'header' in node:
        node['header'] = get_ast(node['header'])
    if 'children' in node:
        node['children'] = [get_ast(child) for child in node['children']]
    return node