Traversal algorithm working