def handle_metavalues(
    old: DynaBox | dict[str, int] | dict[str, str | int],
    new: Any,
    list_merge: Literal["merge", "shallow", "deep"] = "merge",
) -> None:
    """
    Cleanup of MetaValues on new dict
    :param old: old values
    :param new: new values
    :param list_merge: Methods to use to merge lists
        - merge: default merge behavior, i.e. (unique) concatenation
        - shallow: replace the top-most level list of the nested structure
        - deep: iteratively traverse the nested structure and replace
            the element in the list at the level specified by the full_path
    """

    for key in list(new.keys()):
        # MetaValue instances
        if getattr(new[key], "_dynaconf_reset", False):  # pragma: no cover
            # a Reset on `new` triggers reasign of existing data
            new[key] = new[key].unwrap()
        elif getattr(new[key], "_dynaconf_del", False):
            # a Del on `new` triggers deletion of existing data
            new.pop(key, None)
            old.pop(key, None)
        elif getattr(new[key], "_dynaconf_merge", False):
            # a Merge on `new` triggers merge with existing data
            new[key] = object_merge(
                old.get(key),
                new[key].unwrap(),
                unique=new[key].unique,
            )
        elif getattr(new[key], "_dynaconf_insert", False):
            # Insert on `new` triggers insert with existing data
            # if existing is a list it inserts at specified .index
            # if existing is not a list it creates a new list with the value
            existing = old.get(key)  # keep the same reference
            if isinstance(existing, list):  # perform insert on it
                existing.insert(new[key].index, new[key].unwrap())
                new[key] = existing
            else:
                new[key] = [new[key].unwrap()]

        # Data structures containing merge tokens
        if isinstance(new.get(key), (list, tuple)):
            has_merge = "dynaconf_merge" in new[key]
            has_merge_unique = "dynaconf_merge_unique" in new[key]
            if has_merge or has_merge_unique:
                value = list(new[key])
                unique = False

                try:
                    value.remove("dynaconf_merge")
                except ValueError:
                    value.remove("dynaconf_merge_unique")
                    unique = True

                for item in old.get(key)[::-1]:
                    if unique and item in value:
                        continue
                    value.insert(0, item)

                new[key] = value

        elif isinstance(new.get(key), dict):
            local_merge = new[key].pop(
                "dynaconf_merge", new[key].pop("dynaconf_merge_unique", None)
            )
            if local_merge not in (True, False, None) and not new[key]:
                # In case `dynaconf_merge:` holds value not boolean - ref #241
                new[key] = local_merge

            if local_merge:
                new[key] = object_merge(
                    old.get(key), new[key], list_merge=list_merge
                )

    Cleanup of MetaValues on new dict
    :param old: old values
    :param new: new values
    :param list_merge: Methods to use to merge lists
        - merge: default merge behavior, i.e. (unique) concatenation
        - shallow: replace the top-most level list of the nested structure
        - deep: iteratively traverse the nested structure and replace
            the element in the list at the level specified by the full_path
    
dynaconf/utils/__init__.py