def deref_tag(tag):
    """Recursively dereference a tag and return the resulting object"""
    while True:
        try:
            tag = tag.object
        except AttributeError:
            break
    return tag
