Document document = DocumentHelper.createDocument();
DependencyNodeVisitor visitor = new XmlSerializingDependencyNodeVisitor( document );
// TODO: remove the need for this when the serializer can calculate last nodes from visitor calls only
visitor = new BuildingDependencyNodeVisitor( visitor );
CollectingDependencyNodeVisitor collectingVisitor = new CollectingDependencyNodeVisitor();
DependencyNodeVisitor firstPassVisitor =
new FilteringDependencyNodeVisitor( collectingVisitor, StateDependencyNodeFilter.INCLUDED );
rootNode.accept( firstPassVisitor );