def METHOD_NAME(section, key, global_only=False):
    """Remove key from specified section or remove sections."""
    config_filter = ConfigFilter.GLOBAL_ONLY
    if not global_only:
        config_filter = ConfigFilter.LOCAL_ONLY
        _check_config_is_not_readonly(section, key)
    value = None
    config = load_config(config_filter=config_filter)
    removed_sections = []
    if section in config:
        if key == "*":
            value = config.pop(section)
        else:
            value = config[section].pop(key, None)
            if not config[section].keys():
                removed_sections.append(section)
    elif section.endswith("*"):
        section_prefix = section[:-1]
        for section in config:
            if section.startswith(section_prefix):
                value = config[section]
                removed_sections.append(section)
    for section in removed_sections:
        config.pop(section)
    if value is not None:
        store_config(config, global_only=global_only)
    return value