Fixes #23837: Replace list.pop(0) by deque.popleft() in dfs function in ...

...migrations