Added method for BFS traversal.