private void mergeNativeTree(Node root) throws IIOInvalidTreeException {
String name = root.getNodeName();
if (name != ((isStream) ? JPEG.nativeStreamMetadataFormatName
: JPEG.nativeImageMetadataFormatName)) {
throw new IIOInvalidTreeException("Invalid root node name: " + name,
root);
}
if (root.getChildNodes().getLength() != 2) { // JPEGvariety and markerSequence
throw new IIOInvalidTreeException(
"JPEGvariety and markerSequence nodes must be present", root);
}
mergeJFIFsubtree(root.getFirstChild());
mergeSequenceSubtree(root.getLastChild());
}