def parsed_function_to_ast(parsed: Parsed, parsed_key):
sub = parsed[parsed_key]<EOL>subtree = {<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT>": sub["<STR_LIT>"],<EOL>"<STR_LIT>": {<EOL>"<STR_LIT:name>": sub["<STR_LIT:name>"],<EOL>"<STR_LIT>": sub["<STR_LIT>"],<EOL>"<STR_LIT>": sub.get("<STR_LIT>", []),<EOL>},<EOL>}<EOL>args = []<EOL>for arg in parsed[parsed_key].get("<STR_LIT:args>", []):<EOL><INDENT>if arg["<STR_LIT:type>"] == "<STR_LIT>":<EOL><INDENT>args.append(parsed_function_to_ast(parsed, arg["<STR_LIT>"]))<EOL><DEDENT>elif arg["<STR_LIT:type>"] == "<STR_LIT>":<EOL><INDENT>args.append(<EOL>{<EOL>"<STR_LIT>": arg["<STR_LIT>"],<EOL>"<STR_LIT:type>": arg["<STR_LIT:type>"],<EOL>"<STR_LIT>": arg["<STR_LIT>"],<EOL>"<STR_LIT>": {<EOL>"<STR_LIT>": arg["<STR_LIT>"],<EOL>"<STR_LIT>": arg["<STR_LIT>"],<EOL>"<STR_LIT>": arg["<STR_LIT>"],<EOL>"<STR_LIT>": arg["<STR_LIT>"],<EOL>},<EOL>}<EOL>)<EOL><DEDENT>elif arg["<STR_LIT:type>"] == "<STR_LIT>":<EOL><INDENT>args.append({"<STR_LIT>": arg["<STR_LIT>"], "<STR_LIT:type>": arg["<STR_LIT:type>"], "<STR_LIT>": arg["<STR_LIT>"]})<EOL><DEDENT><DEDENT>subtree["<STR_LIT:args>"] = copy.deepcopy(args)<EOL>return subtree<EOL>
Create AST for top-level functions