I think this is not the right way to solve it. It's better to throw an exception here if we get some unexpected key type, IMHO.