def prune(d):
    """If possible, make the multi-valued mapping `d` single-valued.

    If all value sets of `d` have exactly one member, remove the set layer,
    and return the single-valued dictionary.

    Else return `d` as-is.
    """
    if all(len(v) == 1 for v in d.values()):
        return {k: next(iter(v)) for k, v in d.items()}
    return d