def flatten(obj: dict):
    """
    Flatten nested dictionaries, it does not namespace the keys, so possible
    conflicts can arise. Conflicts are not allowed, so exception is raised if a
    key should be overwritten.

    :param obj:
    :raises KeyError: If there is already existing key in the new dict
    :return:
    """

    def _flatten(obj: dict, new_obj):
        for k, v in obj.items():
            if isinstance(v, dict):
                _flatten(v, new_obj)
            else:
                if k in new_obj:
                    KeyError(f'Key \'{k}\' is already present in the dict!')

                new_obj[k] = v

        return new_obj

    return _flatten(obj, {})