def _build_identifier_trait_items_dictionary(
                self,
            ) -> typing.Dict[str, typing.List[typing.Dict]]:  # type: ignore[type-arg]
                """
                build a dictionary of the form
                {"identifier": [{"trait_key": "key", "trait_value": "value"}, ...]}
                """
                identity_trait_items = defaultdict(list)
                for item in self.validated_data:
                    # item will be in the format:
                    # {"identity": {"identifier": "foo"}, "trait_key": "foo", "trait_value": "bar"}
                    identity_trait_items[item["identity"]["identifier"]].append(
                        dict((k, v) for k, v in item.items() if k != "identity")
                    )
                return identity_trait_items

                build a dictionary of the form
                {"identifier": [{"trait_key": "key", "trait_value": "value"}, ...]}
                
api/environments/sdk/serializers.py