# Buggy code
async def get_services(self) -> BleakGATTServiceCollection:
    """Get all services registered for this GATT server.

    Returns:
       A :py:class:`bleak.backends.service.BleakGATTServiceCollection` with this device's services tree.

    """
    if self._services_resolved:
        return self.services

    while True:
        properties = await self._get_device_properties()
        services_resolved = properties.get("ServicesResolved", False)
        if services_resolved:
            break
        await asyncio.sleep(0.02, loop=self.loop)

    logger.debug("Get Services...")
    objs = await get_managed_objects(
        self._bus, self.loop, self._device_path + "/service"
    )

    for object_path, interfaces in objs.items():
        logger.debug(utils.format_GATT_object(object_path, interfaces))
        if defs.GATT_SERVICE_INTERFACE in interfaces:
            service = interfaces.get(defs.GATT_SERVICE_INTERFACE)
            self.services.add_service(BleakGATTServiceBlueZDBus(service, object_path))
        elif defs.GATT_CHARACTERISTIC_INTERFACE in interfaces:
            char = interfaces.get(defs.GATT_CHARACTERISTIC_INTERFACE)
            _service = list(filter(lambda x: x.path == char["Service"], self.services))
            self.services.add_characteristic(
                BleakGATTCharacteristicBlueZDBus(char, object_path, _service[0].uuid)
            )
            self._char_path_to_uuid[object_path] = char.get("UUID")
        elif defs.GATT_DESCRIPTOR_INTERFACE in interfaces:
            desc = interfaces.get(defs.GATT_DESCRIPTOR_INTERFACE)
            _characteristic = list(
                filter(
                    lambda x: x.path == desc["Characteristic"],
                    self.services.characteristics.values(),
                )
            )
            self.services.add_descriptor(
                BleakGATTDescriptorBlueZDBus(desc, object_path, _characteristic[0].uuid)
            )

    self._services_resolved = True
    return self.services


# Traceback (builtins.AttributeError)
Unhandled Error
Traceback (most recent call last):
File "/home/usr/dir/virtualEnv/lib/python3.6/site-packages/txdbus/protocol.py", line 141, in dataReceived
self.rawDBusMessageReceived(raw_msg)
File "/home/usr/dir/virtualEnv/lib/python3.6/site-packages/txdbus/protocol.py", line 262, in rawDBusMessageReceived
self.signalReceived(m)
File "/home/usr/dir/virtualEnv/lib/python3.6/site-packages/txdbus/client.py", line 643, in signalReceived
self.router.routeMessage(msig)
File "/home/usr/dir/virtualEnv/lib/python3.6/site-packages/txdbus/router.py", line 128, in routeMessage
r.match(m)
--- <exception caught here> ---
File "/home/usr/dir/virtualEnv/lib/python3.6/site-packages/txdbus/router.py", line 67, in match
self.callback(m)
File "/home/usr/dir/virtualEnv/lib/python3.6/site-packages/bleak/backends/bluezdbus/discovery.py", line 109, in parse_msg
*_device_info(msg_path, devices.get(msg_path))
File "/home/usr/dir/virtualEnv/lib/python3.6/site-packages/bleak/backends/bluezdbus/discovery.py", line 39, in _device_info
name = props.get("Name", props.get("Alias", path.split("/")[-1]))
builtins.AttributeError: 'NoneType' object has no attribute 'get'

# Fixed code
async def get_services(self) -> BleakGATTServiceCollection:
    """Get all services registered for this GATT server.

    Returns:
       A :py:class:`bleak.backends.service.BleakGATTServiceCollection` with this device's services tree.

    """
    if self._services_resolved:
        return self.services

    while True:
        properties = await self._get_device_properties()
        services_resolved = properties.get("ServicesResolved", False)
        if services_resolved:
            break
        await asyncio.sleep(0.02, loop=self.loop)

    logger.debug("Get Services...")
    objs = await get_managed_objects(
        self._bus, self.loop, self._device_path + "/service"
    )

    # There is no guarantee that services are listed before characteristics
    # Managed Objects dict.
    # Need multiple iterations to construct the Service Collection

    _chars, _descs = [], []

    for object_path, interfaces in objs.items():
        logger.debug(utils.format_GATT_object(object_path, interfaces))
        if defs.GATT_SERVICE_INTERFACE in interfaces:
            service = interfaces.get(defs.GATT_SERVICE_INTERFACE)
            self.services.add_service(BleakGATTServiceBlueZDBus(service, object_path))
        elif defs.GATT_CHARACTERISTIC_INTERFACE in interfaces:
            char = interfaces.get(defs.GATT_CHARACTERISTIC_INTERFACE)
            _chars.append([char, object_path])
        elif defs.GATT_DESCRIPTOR_INTERFACE in interfaces:
            desc = interfaces.get(defs.GATT_DESCRIPTOR_INTERFACE)
            _descs.append([desc, object_path])

    for char, object_path in _chars:
        _service = list(filter(lambda x: x.path == char["Service"], self.services))
        self.services.add_characteristic(
            BleakGATTCharacteristicBlueZDBus(char, object_path, _service[0].uuid)
        )
        self._char_path_to_uuid[object_path] = char.get("UUID")

    for desc, object_path in _descs:
        _characteristic = list(
            filter(
                lambda x: x.path == desc["Characteristic"],
                self.services.characteristics.values(),
            )
        )
        self.services.add_descriptor(
            BleakGATTDescriptorBlueZDBus(desc, object_path, _characteristic[0].uuid)
        )

    self._services_resolved = True
    return self.services