Use walk_preorder instead of manual visiting