code: def _build_dictionary(self, results):
          
          foreign = self._first_key
  
          dictionary = {}
  
          for result in results:
              key = getattr(result, foreign)
              if key not in dictionary:
                  dictionary[key] = []
  
              dictionary[key].append(result)
  
          return dictionary
docs: Build model dictionary keyed by the relation's foreign key.
  
          :param results: The results
          :type results: Collection
  
          :rtype: dict