No values besides `keys[-1]` are ever looked at, so it can just be a local `last_key` var.