def replace_password(d : dict) -> dict:
    """
    Recursively replace passwords in a dictionary.
    """
    _d = d.copy()
    for k, v in d.items():
        if isinstance(v, dict):
            _d[k] = replace_password(v)
        elif 'password' in str(k).lower():
            _d[k] = ''.join(['*' for char in str(v)])
    return _d