@classmethod
def converted(cls, obj):
    """Return the obj or a registered conversion object. If obj is not an
        Element instance and no conversion is registered for the given type,
        then a TypeError is raised"""
    if isinstance(obj, cls.BASE_ELEMENT):
        return obj
    else:
        try:
            obj = cls.CONVERSIONS[type(obj)](obj)
        except KeyError:
            raise TypeError('Unsupported type: %s' % type(obj).__name__)
    assert isinstance(obj, cls.BASE_ELEMENT
        ), 'Converted to a non-element type %s' % type(obj).__name__
    return obj
