Speaking about naming I think that this function is perfectly right but may be you want to rename `_types` and `types` to `keys` ?