BFS and DFS with collections.deque added.