move visitor logic to tree