def METHOD_NAME(enrolled_device, date=None):
    major_update = minor_update = patch_update = rsr_update = None
    current_comparable_os_version = enrolled_device.comparable_os_version
    if current_comparable_os_version == (0, 0, 0, ""):
        logger.debug("Enrolled device %s: no comparable OS version", enrolled_device.udid)
        return major_update, minor_update, patch_update, rsr_update
    current_major, current_minor, current_patch, current_extra = current_comparable_os_version
    try:
        device_id = enrolled_device.device_information["SoftwareUpdateDeviceID"]
    except (KeyError, TypeError):
        logger.debug("Enrolled device %s: no SoftwareUpdateDeviceID found", enrolled_device.udid)
        return major_update, minor_update, patch_update, rsr_update
    if not isinstance(device_id, str):
        # should never happen
        logger.error("Enrolled device %s: SoftwareUpdateDeviceID is not a str", enrolled_device.udid)
        return major_update, minor_update, patch_update, rsr_update
    if not device_id:
        # should never happen
        logger.error("Enrolled device %s: SoftwareUpdateDeviceID is an empty str", enrolled_device.udid)
        return major_update, minor_update, patch_update, rsr_update
    # filter the choices
    if date is None:
        date = datetime.date.today()
    for software_update in SoftwareUpdate.objects.filter(
        Q(public=False) | Q(extra__gt=""),
        Q(prerequisite_build="") | Q(prerequisite_build=enrolled_device.current_build_version),
        availability__contains=date,
        softwareupdatedeviceid__device_id=device_id
    ):
        if software_update.comparable_os_version <= current_comparable_os_version:
            # not an update for the device
            continue
        if software_update.major != current_major:
            if major_update is None or (major_update.comparable_os_version < software_update.comparable_os_version):
                major_update = software_update
        elif software_update.minor != current_minor:
            if minor_update is None or (minor_update.comparable_os_version < software_update.comparable_os_version):
                minor_update = software_update
        elif software_update.patch != current_patch:
            if patch_update is None or (patch_update.comparable_os_version < software_update.comparable_os_version):
                patch_update = software_update
        elif software_update.extra != current_extra:
            if rsr_update is None or (rsr_update.comparable_os_version < software_update.comparable_os_version):
                rsr_update = software_update
    return major_update, minor_update, patch_update, rsr_update