### Question:
DomUtil { public static Node getLastNamedChildNode(Node root, String nodeName) { Node current = root.getLastChild(); while (current != null) { if (current.getNodeName().equalsIgnoreCase(nodeName)) { return current; } current = current.getPreviousSibling(); } return null; } private  DomUtil(); static Node getFirstNamedChildNode(Node root, String nodeName); static Node getLastNamedChildNode(Node root, String nodeName); static List<Element> getElementsByTagNameCaseInsensitive(Document doc,
      final Set<String> lowerCaseNames);  }### Answer:
@Test public void getLastNamedChildNode() throws Exception { Element root = XmlUtil.parse(XML); assertTrue(DomUtil.getLastNamedChildNode(root, "element") != null); assertEquals("two", DomUtil.getLastNamedChildNode(root, "element").getTextContent()); assertEquals("not real", DomUtil.getLastNamedChildNode(root, "other").getTextContent()); assertNull("Did not return null for missing element.", DomUtil.getLastNamedChildNode(root, "fake")); }
@Test public void getLastNamedChildNode() { assertEquals("two", DomUtil.getLastNamedChildNode(root, "element").getTextContent()); assertEquals("not real", DomUtil.getLastNamedChildNode(root, "other").getTextContent()); assertNull("Did not return null for missing element.", DomUtil.getLastNamedChildNode(root, "fake")); }