Helper method and class for using builder pattern to visit each
component in a tree