This whole thing can just be `filter(lambda i: i[0] == x, mappings)`. Usually I prefer loops over filter, but when you are modifying the loop you are iterating over, that's a bad sign.