    /*
     * call-seq:
     *  dup
     *
     * Copy this node.  An optional depth may be passed in, but it defaults
     * to a deep copy.  0 is a shallow copy, 1 is a deep copy.
     */
    static VALUE duplicate_node(int argc, VALUE *argv, VALUE self)
    {
      VALUE level;
      xmlNodePtr node, dup;

      if(rb_scan_args(argc, argv, "01", &level) == 0)
        level = INT2NUM((long)1);

      Data_Get_Struct(self, xmlNode, node);

      dup = xmlDocCopyNode(node, node->doc, (int)NUM2INT(level));
      if(dup == NULL) return Qnil;

      NOKOGIRI_ROOT_NODE(dup);

      return Nokogiri_wrap_xml_node(rb_obj_class(self), dup);
    }