def KeyWithHighestValue(d, forbidden_keys=[]):
    """Return the key with the highest value.

    Optionally, a list of forbidden keys can be provided. If so, the function
    will return the key with the next-highest value, but which is not
    forbidden.
    """
    mv = -1
    mk = None
    for k, v in d.items():
        if k in forbidden_keys:
            continue
        if v > mv:
            mk = k
            mv = v
    return mk