code: private static Node cloneNode(final Node dom) {
          final Transformer transformer;
          try {
              transformer = TransformerFactory.newInstance().newTransformer();
          } catch (final TransformerConfigurationException ex) {
              throw new IllegalStateException(
                  "Could not create new Transformer to clone Node",
                  ex
              );
          }
          final DOMSource source = new DOMSource(dom);
          try {
              final DOMResult result = new DOMResult();
              transformer.transform(source, result);
              return result.getNode();
          } catch (final TransformerException ex) {
              throw new IllegalArgumentException(
                  String.format(
                      "Could not clone Node %s with Transformer %s",
                      source,
                      transformer
                  ),
                  ex
              );
          }
      }
docs: Create Node clone.
  @param dom Node to clone
  @return Cloned Node