def METHOD_NAME(value: Any) -> uuid.UUID | None:
    if isinstance(value, uuid.UUID) or value is None:
        return value
    try:
        value = uuid.UUID(hex=value)
    except (TypeError, ValueError):
        value = uuid.UUID(bytes=value)
    return cast("uuid.UUID | None", value)