def METHOD_NAME(sender, **kwargs):
    """
    Checks for layers embedded from the deleted layer,
    deletes them accordingly and remove the whole project if empty
    """
    layer = kwargs['instance']
    # If it is embedded make sure it is removed from the project
    # because it may be a cascade
    if layer.parent_project is not None:
        project = QgsProject()
        assert project.read(layer.project.qgis_file.file.name)
        project.removeMapLayers([layer.qgs_layer_id])
        assert project.write()