Keep track of the depth in the dfs iterator.