def METHOD_NAME(db, dataset_dict):
    _id = dataset_dict["_id"]
    name = dataset_dict.get("name", None)
    slug = dataset_dict.get("slug", None)
    existing_names = set()
    existing_slugs = set()
    for d in db.datasets.find({"_id": {"$ne": _id}}, {"name": 1, "slug": 1}):
        if "name" in d:
            existing_names.add(d["name"])
        if "slug" in d:
            existing_slugs.add(d["slug"])
    if name is None:
        name = _get_default_dataset_name(existing_names)
    if slug is None:
        try:
            # Give the user a one-time pass if they have a really long dataset
            # name to have a slug-friendly name that's shorter
            slug = _to_slug(name[: _NAME_LENGTH_RANGE[1]])
        except Exception as e:
            old_name = name
            name = _get_default_dataset_name(existing_names)
            slug = _to_slug(name)
            logger.warning(e)
            logger.warning("Renaming dataset '%s' to '%s'", old_name, name)
    if name in existing_names or slug in existing_slugs:
        old_name = name
        # Make a valid, unique name that resembles the original
        name = _get_default_dataset_name(existing_names)
        name = old_name + "-RENAMED-" + name
        name = name[-_NAME_LENGTH_RANGE[1] :]
        slug = _to_slug(name)
        logger.warning(
            "Dataset name '%s' conflicts with another dataset's name", old_name
        )
        logger.warning("Renaming dataset '%s' to '%s'", old_name, name)
    dataset_dict["name"] = name
    dataset_dict["slug"] = slug