Fixed bug in traversal logic.