backports normalizeKeys() method