It sounds like we could first check what the type of key is and then do the appropriate conversion.
That way we don't need to do equals multiple times.