code: def _build_dictionary(self, models):
          
          for model in models:
              key = getattr(model, self._morph_type, None)
              if key:
                  foreign = getattr(model, self._foreign_key)
                  if key not in self._dictionary:
                      self._dictionary[key] = {}
  
                  if foreign not in self._dictionary[key]:
                      self._dictionary[key][foreign] = []
  
                  self._dictionary[key][foreign].append(model)
docs: Build a dictionary with the models.
  
          :param models: The models
          :type models: Collection