'Remove element named \'name\' from the collection'

def remove(self, name, with_delete=True, with_sync=True, with_triggers=True, recursive=False, logger=None):

    name = name.lower()
    if (not recursive):
        for v in self.collection_mgr.profiles():
            if (v.distro and (v.distro.lower() == name)):
                raise CX((_('removal    would    orphan    profile:    %s') % v.name))
    obj = self.find(name=name)
    if (obj is not None):
        kernel = obj.kernel
        if recursive:
            kids = obj.get_children()
            for k in kids:
                self.collection_mgr.api.remove_profile(k.name, recursive=recursive, delete=with_delete, with_triggers=with_triggers, logger=logger)
        if with_delete:
            if with_triggers:
                utils.run_triggers(self.collection_mgr.api, obj, '/var/lib/cobbler/triggers/delete/distro/pre/*', [], logger)
            if with_sync:
                lite_sync = action_litesync.CobblerLiteSync(self.collection_mgr, logger=logger)
                lite_sync.remove_single_distro(name)
        self.lock.acquire()
        try:
            del self.listing[name]
        finally:
            self.lock.release()
        self.collection_mgr.serialize_delete(self, obj)
        if with_delete:
            if with_triggers:
                utils.run_triggers(self.collection_mgr.api, obj, '/var/lib/cobbler/triggers/delete/distro/post/*', [], logger)
                utils.run_triggers(self.collection_mgr.api, obj, '/var/lib/cobbler/triggers/change/*', [], logger)
        settings = self.collection_mgr.settings()
        possible_storage = glob.glob((settings.webdir + '/distro_mirror/*'))
        path = None
        for storage in possible_storage:
            if (os.path.dirname(obj.kernel).find(storage) != (-1)):
                path = storage
                continue
        if (with_delete and (path is not None) and os.path.exists(path) and (kernel.find(settings.webdir) != (-1))):
            found = False
            distros = self.api.distros()
            for d in distros:
                if (d.kernel.find(path) != (-1)):
                    found = True
            if (not found):
                utils.rmtree(path)
