private void visitNodes(List<MessageFragment> result, Branch root) {
        Iterator<Node> iterator = root.nodeIterator();
        while (iterator.hasNext()) {
            Node node = iterator.next();
            String xml = node.asXML();
            if (node.getNodeType() == Node.COMMENT_NODE) {
                result.add(new SimpleNonlocalizableTextFragment(xml));
            } else if (node.getNodeType() == Node.TEXT_NODE) {
                visitTextNode(result, xml);
            } else if (node.getNodeType() == Node.ELEMENT_NODE) {
                String startTag = xml.trim().replaceAll(TAG_PATTERN.pattern(), "$1");
                String endTag = xml.trim().replaceAll(TAG_PATTERN.pattern(), "$3");
                if (startTag.contains(XLIFF_TAG)) {
                    result.add(new SimpleNonlocalizableTextFragment(xml));
                } else {
                    result.add(new SimpleNonlocalizableTextFragment(startTag));
                    if (((Element) node).isTextOnly()) {
                        visitTextNode(result, node.getText());
                    } else {
                        visitNodes(result, (Element) node);
                    }
                    result.add(new SimpleNonlocalizableTextFragment(endTag));
                }
            } else if (node.getNodeType() == Node.NAMESPACE_NODE) {
                // do nothing
            } else {
                result.add(new SimpleNonlocalizableTextFragment(xml));
            }
        }
    }