move the code in the block below to a dedicated function `_squash_nested_dict`?