def METHOD_NAME(  # pylint: disable=too-many-return-statements
    service_type: str, service_name: str, properties: Mapping[str, str]
) -> Optional[str]:
    """Return unique identifier from a Zeroconf service.
    `service_type` is the Zeroconf service type (e.g. *_mediaremotetv._tcp.local*),
    `service_name` name of the service (e.g. *Office* or *Living Room*) and
    `properties` all key-value properties belonging to the service.
    The unique identifier is returned if available, otherwise `None` is returned.
    """
    if service_type in [DEVICE_SERVICE, HOMESHARING_SERVICE]:
        return service_name.split("_")[0]
    if service_type == HSCP_SERVICE:
        return properties.get("Machine ID")
    if service_type == MEDIAREMOTE_SERVICE:
        return properties.get("UniqueIdentifier")
    if service_type == AIRPLAY_SERVICE:
        return properties.get("deviceid")
    if service_type == COMPANION_SERVICE:
        # Apple TV devices on tvOS 16 (maybe earlier) have a static rpMRtID
        # identifier.
        return properties.get("rpmrtid")
    if service_type == RAOP_SERVICE:
        split = service_name.split("@", maxsplit=1)
        # Normally a RAOP devices announces with "id@name" as zeroconf name. But some
        # devices seems to break from this behavior and just use "name", thus leaving
        # out the id. Some of these devices however have the public key ("pk")
        # available as an attribute so that can be used as an identifier in that case.
        if len(split) == 2:
            return split[0]
        return properties.get("pk")
    return None