def _max_at_least_k(k, counter=None):
    """
    Get largest key of `counter` whose value is at least `k`.

    :param counter: dict with keys that support comparison operators
    :param k: lower bound
    :return: largest key of `counter`
    """
    assert counter, "counter must be non-empty and not `None`."
    return max(filter(lambda r: counter[r] >= k, counter.keys()),
               default=min(counter.keys()))