A variant of DFS that limits the maximum depth of nodes to be explored, to avoid going too deep into the graph.