def restrict_keys(d: dict, domain) -> dict:
    """Remove from d all items whose key is not in domain; return d.
    >>> d = {'a': 1, 'b': 2}
    >>> dr = restrict_keys(d, {'a', 'c'})
    >>> dr
    {'a': 1}
    >>> d == dr
    True
    """
    for k in set(d):
        if k not in domain:
            del d[k]
    return d