def rec_copy(d: dict) -> dict:
    """Local replacement for copy.deepcopy(), as transcrypt cannot import the copy module.
    We recursively make a copy of a dict.
    This code can only handle values that are dicts or scaler types
    """
    newdct = dict()
    for k, v in d.items():
        if isinstance(v, dict):
            newdct[k] = rec_copy(v)
        else:
            newdct[k] = v
    return newdct