def _remove_extra_delims(expr, ldelim="<STR_LIT:(>", rdelim="<STR_LIT:)>", fcount=None):
if not expr.strip():<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>fcount = [<NUM_LIT:0>] if fcount is None else fcount<EOL>tfuncs = _get_functions(expr, ldelim=ldelim, rdelim=rdelim)<EOL>for fdict in reversed(tfuncs):<EOL><INDENT>fcount[<NUM_LIT:0>] += <NUM_LIT:1><EOL>fdict["<STR_LIT>"] = "<STR_LIT>" + str(fcount[<NUM_LIT:0>])<EOL>expr = expr[: fdict["<STR_LIT:start>"]] + fdict["<STR_LIT>"] + expr[fdict["<STR_LIT>"] + <NUM_LIT:1> :]<EOL>fdict["<STR_LIT>"] = _remove_extra_delims(<EOL>fdict["<STR_LIT>"], ldelim=ldelim, rdelim=rdelim, fcount=fcount<EOL>)<EOL><DEDENT>expr = _build_expr(<EOL>_parse_expr(expr, ldelim=ldelim, rdelim=rdelim), ldelim=ldelim, rdelim=rdelim<EOL>)<EOL>for fdict in tfuncs:<EOL><INDENT>expr = expr.replace(<EOL>fdict["<STR_LIT>"], fdict["<STR_LIT>"] + ldelim + fdict["<STR_LIT>"] + rdelim<EOL>)<EOL><DEDENT>return expr<EOL>
Remove unnecessary delimiters (parenthesis, brackets, etc.).

Internal function that can be recursed