def annotation_filter(annotations, condition):
    """
    Filter annotations.
    `annotations`: the annotations to filter
    `condition`: the filter callback
    return: the filtered annotations
    """
    filtered = dict()
    for (key, value) in annotations.items():
        if condition(key, value):
            filtered[key] = value
    return filtered