added tree visitor pattern