Add an invert utility function that takes a mapping table and returns its inverse.  It doesn't deal with duplicates at all.  Caveat emptor.