Adding traversal algorithm