def depth_limited_search(problem, limit=<NUM_LIT:50>):
def recursive_dls(node, problem, limit):<EOL><INDENT>if problem.goal_test(node.state):<EOL><INDENT>return node<EOL><DEDENT>elif node.depth == limit:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>cutoff_occurred = False<EOL>for child in node.expand(problem):<EOL><INDENT>result = recursive_dls(child, problem, limit)<EOL>if result == '<STR_LIT>':<EOL><INDENT>cutoff_occurred = True<EOL><DEDENT>elif result is not None:<EOL><INDENT>return result<EOL><DEDENT><DEDENT>return if_(cutoff_occurred, '<STR_LIT>', None)<EOL><DEDENT><DEDENT>return recursive_dls(Node(problem.initial), problem, limit)<EOL>
[Fig. 3.17]