def orthologize(ast, bo, species_id: str):
<EOL>if not species_id:<EOL><INDENT>bo.validation_messages.append(<EOL>("<STR_LIT>", "<STR_LIT>")<EOL>)<EOL>return ast<EOL><DEDENT>if isinstance(ast, NSArg):<EOL><INDENT>if ast.orthologs:<EOL><INDENT>if ast.orthologs.get(species_id, None):<EOL><INDENT>orthologized_nsarg_val = ast.orthologs[species_id]["<STR_LIT>"]<EOL>ns, value = orthologized_nsarg_val.split("<STR_LIT::>")<EOL>ast.change_nsvalue(ns, value)<EOL>ast.canonical = ast.orthologs[species_id]["<STR_LIT>"]<EOL>ast.decanonical = ast.orthologs[species_id]["<STR_LIT>"]<EOL>ast.orthologized = True<EOL>bo.ast.species.add(<EOL>(species_id, ast.orthologs[species_id]["<STR_LIT>"])<EOL>)<EOL><DEDENT>else:<EOL><INDENT>bo.ast.species.add((ast.species_id, ast.species_label))<EOL>bo.validation_messages.append(<EOL>("<STR_LIT>", f"<STR_LIT>")<EOL>)<EOL><DEDENT><DEDENT>elif ast.species_id:<EOL><INDENT>bo.ast.species.add((ast.species_id, ast.species_label))<EOL><DEDENT><DEDENT>if hasattr(ast, "<STR_LIT:args>"):<EOL><INDENT>for arg in ast.args:<EOL><INDENT>orthologize(arg, bo, species_id)<EOL><DEDENT><DEDENT>return ast<EOL>
Recursively orthologize BEL Entities in BEL AST using API endpoint

    NOTE: - will take first ortholog returned in BEL.bio API result (which may return more than one ortholog)

    Args:
        ast (BEL): BEL AST
        endpoint (str): endpoint url with a placeholder for the term_id

    Returns:
        BEL: BEL AST