def parsed_to_ast(parsed: Parsed, errors: Errors, component_type: str = "<STR_LIT>"):
ast = {}<EOL>sorted_keys = sorted(parsed.keys())<EOL>for key in sorted_keys:<EOL><INDENT>if parsed[key]["<STR_LIT:type>"] == "<STR_LIT>":<EOL><INDENT>nested_component_stack = ["<STR_LIT>", "<STR_LIT:object>"]<EOL><DEDENT><DEDENT>if component_type:<EOL><INDENT>component_stack = [component_type]<EOL><DEDENT>else:<EOL><INDENT>component_stack = ["<STR_LIT>", "<STR_LIT:object>"]<EOL><DEDENT>for key in sorted_keys:<EOL><INDENT>if parsed[key]["<STR_LIT:type>"] == "<STR_LIT>" and parsed[key]["<STR_LIT>"] == "<STR_LIT>":<EOL><INDENT>ast[component_stack.pop(<NUM_LIT:0>)] = parsed_function_to_ast(parsed, key)<EOL><DEDENT>elif parsed[key]["<STR_LIT:type>"] == "<STR_LIT>" and "<STR_LIT>" not in ast:<EOL><INDENT>ast["<STR_LIT>"] = {<EOL>"<STR_LIT:name>": parsed[key]["<STR_LIT:name>"],<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT>": key,<EOL>}<EOL><DEDENT>elif parsed[key]["<STR_LIT:type>"] == "<STR_LIT>":<EOL><INDENT>ast["<STR_LIT>"] = {}<EOL>for nested_key in sorted_keys:<EOL><INDENT>if nested_key <= key:<EOL><INDENT>continue<EOL><DEDENT>if (<EOL>parsed[nested_key]["<STR_LIT:type>"] == "<STR_LIT>"<EOL>and parsed[nested_key]["<STR_LIT>"] == "<STR_LIT>"<EOL>):<EOL><INDENT>ast["<STR_LIT>"][<EOL>nested_component_stack.pop(<NUM_LIT:0>)<EOL>] = parsed_function_to_ast(parsed, nested_key)<EOL><DEDENT>elif (<EOL>parsed[nested_key]["<STR_LIT:type>"] == "<STR_LIT>"<EOL>and "<STR_LIT>" not in ast["<STR_LIT>"]<EOL>):<EOL><INDENT>ast["<STR_LIT>"]["<STR_LIT>"] = {<EOL>"<STR_LIT:name>": parsed[nested_key]["<STR_LIT:name>"],<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT>": parsed[nested_key]["<STR_LIT>"],<EOL>}<EOL><DEDENT><DEDENT>return ast, errors<EOL><DEDENT><DEDENT>return ast, errors<EOL>
Convert parsed data struct to AST dictionary

    Args:
        parsed:
        errors:
        component_type: Empty string or 'subject' or 'object' to indicate that we
            are parsing the subject or object field input