def filter_dict(it, d):
    """
    Filters a dictionary to all elements in a given iterable
    :param it: iterable containing all keys which should still be in the dictionary
    :param d: the dictionary to filter
    :return: dictionary with all elements of d whose keys are also in it
    """
    if d is None:
        return {}
    return dict(filter(lambda cf: cf[0] in it, d.items()))