def METHOD_NAME(self, path, value, separator=".", commit=False):
    """
    Sets a preference value based on its path. If the preference is nested inside
    categories and subcategories, these will be created in the process. If the
    preference already exists its value will be overwritten. Categories and
    subcategories cannot be overwriten with values, a TypeError exception will be
    raised in that case. This behavior is the same for preferences that cannot be
    changed to categories later on.
    This function does not commit changes to the database if True is not provided
    as value for the commit named parameter.
    """
    data = self.data
    keys = path.split(separator)
    # Look only for categories for now, excluding the name of the value
    for i, key in enumerate(keys[:-1]):
        if key in data and type(data[key]) == dict:
            # Step by step down the dicts
            data = data[key]
        elif key in data:
            wrong_path = separator.join(path.split(separator)[: i + 1])
            raise TypeError(f"Cannot convert category '{wrong_path}' to a value.")
        else:
            # Create a new category
            data = data.setdefault(key, {})
    # Now set the actual value of the preference
    key = keys[-1]
    if key in data and type(data[key]) == dict:
        raise TypeError(
            f"'{path}' is a category, it cannot be converted to a value."
        )
    else:
        data[key] = value
    if commit:
        self.save()