docs: def parsed_function_to_ast(parsed: Parsed, parsed_key):
      """Create AST for top-level functions"""
  
      sub = parsed[parsed_key]
  
      subtree = {
          "type": "Function",
          "span": sub["span"],
          "function": {
              "name": sub["name"],
              "name_span": sub["name_span"],
              "parens_span": sub.get("parens_span", []),
          },
      }
  
      args = []
      for arg in parsed[parsed_key].get("args", []):
  
          # pdb.set_trace()
  
          if arg["type"] == "Function":
              args.append(parsed_function_to_ast(parsed, arg["span"]))
          elif arg["type"] == "NSArg":
              args.append(
                  {
                      "arg": arg["arg"],
                      "type": arg["type"],
                      "span": arg["span"],
                      "nsarg": {
                          "ns": arg["ns"],
                          "ns_val": arg["ns_val"],
                          "ns_span": arg["ns_span"],
                          "ns_val_span": arg["ns_val_span"],
                      },
                  }
              )
          elif arg["type"] == "StrArg":
              args.append({"arg": arg["arg"], "type": arg["type"], "span": arg["span"]})
  
      subtree["args"] = copy.deepcopy(args)
  
      return subtree