FYI, when a lambda takes a tuple, you can actually "pattern-match" on the tuple like this:

    flter_func = lambda (key, vals): len(vals[0]) > 0 and len(vals[1]) == 0
    map_func = lambda (key, vals): [(a, val) for val in vals[0])