<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_ast_fn(d, spec, parent_function=None):
 """Convert dict AST to object AST Function Args: ast_fn: AST object Function d: AST as dictionary spec: BEL Specification Return: ast_fn """


    if d["type"] == "Function":
        ast_fn = Function(d["function"]["name"], spec, parent_function=parent_function)
        for arg in d["args"]:
            if arg["type"] == "Function":
                ast_fn.add_argument(add_ast_fn(arg, spec, parent_function=ast_fn))
            elif arg["type"] == "NSArg":
                ast_fn.add_argument(
                    NSArg(arg["nsarg"]["ns"], arg["nsarg"]["ns_val"], ast_fn)
                )
            elif arg["type"] == "StrArg":
                ast_fn.add_argument(StrArg(arg["arg"], ast_fn))
    return ast_fn