Add helper method to visit all nodes