This example shows how to use GeoExt.tree.WMSCapabilitiesLoader to populate a tree with the hierarchical structure of a WMS GetCapabilities response. The example also shows how to customize the loader's createNode method to add a checkbox with a checkchange listener that adds and removes layers to and from the map.
See wms-tree.js for the source code.