Added alternative to preorder_traverse