@classmethod
def wrap(cls, element, **kwargs):
    """Wrap an existing adapter.Element OR construct a fresh one.

        This method should usually be invoked from an ElementWrapper subclass
        decorated by Wrapper.pvm_type, and an instance of that subclass will be
        returned.

        If invoked directly from ElementWrapper, we attempt to detect whether
        an appropriate subclass exists based on the Element's tag.  If so, that
        subclass is used; otherwise a generic ElementWrapper is used.

        :param element: An existing adapter.Element to wrap.
        :param **kwargs: Arbitrary attributes to set on the new ElementWrapper.
        :returns: An ElementWrapper (subclass) instance containing the element.
        """
    wcls = cls._class_for_element(element) if cls.schema_type is None else cls
    wrap = wcls()
    wrap.element = element
    for key, val in kwargs.items():
        setattr(wrap, key, val)
    return wrap
