Refactored keeping track of prefix as a decorator of visit.
Changed prefix to level.