@Test
public void testStackOverflowFindLongestMatch() throws Exception {
final Element element = Xml.loadFile(EditLibIntegrationTest.class.getResource("editlib-stackoverflow-findlongestmatch.xml"));
List<String> xpathParts = Lists.newArrayList("gmd:distributionInfo", "gmd:MD_Distribution", "gmd:transferOptions",
"gmd:MD_DigitalTransferOptions", "gmd:onLine", "gmd:CI_OnlineResource", "gmd:linkage");
MetadataSchema schema = _schemaManager.getSchema("iso19139");
final EditLib editLib = new EditLib(_schemaManager);
final Pair<Element, String> longestMatch = editLib.findLongestMatch(element, schema, xpathParts);
assertEquals("gmd:MD_Distribution", longestMatch.one().getQualifiedName());
assertEquals("gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource/gmd:linkage", longestMatch.two());
}