def cursor(<EOL>belstr: str, ast: AST, cursor_loc: int, result: Mapping[str, Any] = None<EOL>) -> Mapping[str, Any]:
log.debug(f"<STR_LIT>")<EOL>log.debug(f"<STR_LIT>")<EOL>if len(belstr) == <NUM_LIT:0>:<EOL><INDENT>return {"<STR_LIT:type>": "<STR_LIT>", "<STR_LIT>": (<NUM_LIT:0>, <NUM_LIT:0>), "<STR_LIT>": "<STR_LIT>"}<EOL><DEDENT>if "<STR_LIT>" in ast and in_span(cursor_loc, ast["<STR_LIT>"]["<STR_LIT>"]):<EOL><INDENT>log.debug("<STR_LIT>")<EOL>completion_text = belstr[ast["<STR_LIT>"]["<STR_LIT>"][<NUM_LIT:0>] : cursor_loc + <NUM_LIT:1>]<EOL>return {<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT>": ast["<STR_LIT>"]["<STR_LIT>"],<EOL>"<STR_LIT>": completion_text,<EOL>}<EOL><DEDENT>elif "<STR_LIT>" not in ast and isinstance(ast, dict):<EOL><INDENT>for key in ast:<EOL><INDENT>if key in ["<STR_LIT>", "<STR_LIT:object>", "<STR_LIT>"]:<EOL><INDENT>log.debug(f"<STR_LIT>")<EOL>result = cursor(belstr, ast[key], cursor_loc, result=result)<EOL>if result:<EOL><INDENT>return result<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if "<STR_LIT>" in ast and in_span(cursor_loc, ast["<STR_LIT>"]):<EOL><INDENT>log.debug("<STR_LIT>")<EOL>if "<STR_LIT>" in ast:<EOL><INDENT>name_span = ast["<STR_LIT>"]["<STR_LIT>"]<EOL>if in_span(cursor_loc, name_span):<EOL><INDENT>return {<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT>": name_span,<EOL>"<STR_LIT>": belstr[name_span[<NUM_LIT:0>] : cursor_loc + <NUM_LIT:1>],<EOL>}<EOL><DEDENT>for idx, arg in enumerate(ast["<STR_LIT:args>"]):<EOL><INDENT>if (<EOL>cursor_loc == ast["<STR_LIT>"]["<STR_LIT>"][<NUM_LIT:0>]<EOL>and ast["<STR_LIT>"]["<STR_LIT>"][<NUM_LIT:1>] == -<NUM_LIT:1><EOL>):<EOL><INDENT>return {<EOL>"<STR_LIT:type>": "<STR_LIT>",  <EOL>"<STR_LIT>": idx,<EOL>"<STR_LIT>": arg["<STR_LIT>"],  <EOL>"<STR_LIT>": ast["<STR_LIT>"]["<STR_LIT:name>"],<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>}<EOL><DEDENT>elif in_span(cursor_loc, arg["<STR_LIT>"]):<EOL><INDENT>log.debug(<EOL>f'<STR_LIT>'<EOL>)<EOL>if arg["<STR_LIT:type>"] == "<STR_LIT>":<EOL><INDENT>if in_span(cursor_loc, arg["<STR_LIT>"]["<STR_LIT>"]):<EOL><INDENT>log.debug("<STR_LIT>")<EOL>return {<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT>": arg["<STR_LIT>"][<EOL>"<STR_LIT>"<EOL>],  <EOL>"<STR_LIT>": idx,<EOL>"<STR_LIT:args>": copy.deepcopy(ast["<STR_LIT:args>"]),<EOL>"<STR_LIT>": ast["<STR_LIT>"]["<STR_LIT:name>"],<EOL>"<STR_LIT>": belstr[<EOL>arg["<STR_LIT>"]["<STR_LIT>"][<NUM_LIT:0>] : cursor_loc + <NUM_LIT:1><EOL>],<EOL>}<EOL><DEDENT>else:<EOL><INDENT>log.debug(f'<STR_LIT>')<EOL>result = cursor(belstr, arg, cursor_loc, result=result)<EOL><DEDENT><DEDENT>elif arg["<STR_LIT:type>"] == "<STR_LIT>":<EOL><INDENT>result = {<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT>": arg["<STR_LIT>"],  <EOL>"<STR_LIT>": idx,<EOL>"<STR_LIT:args>": copy.deepcopy(ast["<STR_LIT:args>"]),<EOL>"<STR_LIT>": ast["<STR_LIT>"]["<STR_LIT:name>"],<EOL>}<EOL>if in_span(cursor_loc, arg["<STR_LIT>"]["<STR_LIT>"]):<EOL><INDENT>result["<STR_LIT>"] = arg["<STR_LIT>"][<EOL>"<STR_LIT>"<EOL>]  <EOL>result["<STR_LIT>"] = belstr[<EOL>arg["<STR_LIT>"]["<STR_LIT>"][<NUM_LIT:0>] : cursor_loc + <NUM_LIT:1><EOL>]<EOL><DEDENT>else:<EOL><INDENT>result["<STR_LIT>"] = belstr[<EOL>arg["<STR_LIT>"]["<STR_LIT>"][<NUM_LIT:0>] : cursor_loc + <NUM_LIT:1><EOL>]<EOL><DEDENT>log.debug(f"<STR_LIT>")<EOL>return result<EOL><DEDENT>elif (<EOL>arg["<STR_LIT:type>"] == "<STR_LIT>"<EOL>):  <EOL><INDENT>if (<EOL>arg["<STR_LIT>"][<NUM_LIT:0>] == arg["<STR_LIT>"][<NUM_LIT:1>]<EOL>):  <EOL><INDENT>completion_text = arg["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>completion_text = belstr[arg["<STR_LIT>"][<NUM_LIT:0>] : cursor_loc + <NUM_LIT:1>]<EOL><DEDENT>return {<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT>": idx,<EOL>"<STR_LIT>": arg["<STR_LIT>"],  <EOL>"<STR_LIT>": ast["<STR_LIT>"]["<STR_LIT:name>"],<EOL>"<STR_LIT>": completion_text.lstrip(),<EOL>}<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>return result<EOL>
Find BEL function or argument at cursor location

    Args:
        belstr: BEL String used to create the completion_text
        ast (Mapping[str, Any]): AST (dict) of BEL String
        cursor_loc (int): given cursor location from input field
            cursor_loc starts at 0, think of it like a block cursor covering each char
        result: used to recursively return the result
    Returns:
        result dict