code: Node cloneOrImportNode(short operation, Node node, boolean deep) {
          NodeImpl copy = shallowCopy(operation, node);
  
          if (deep) {
              NodeList list = node.getChildNodes();
              for (int i = 0; i < list.getLength(); i++) {
                  copy.appendChild(cloneOrImportNode(operation, list.item(i), deep));
              }
          }
  
          notifyUserDataHandlers(operation, node, copy);
          return copy;
      }
docs: Returns a copy of the given node or subtree with this document as its
  owner.
  
  @param operation either {@link UserDataHandler#NODE_CLONED} or
  {@link UserDataHandler#NODE_IMPORTED}.
  @param node a node belonging to any document or DOM implementation.
  @param deep true to recursively copy any child nodes; false to do no such
  copying and return a node with no children.