code: def searchbest(self):
          
          finalsolution = None
          bestscore = None
          for solution in self:
              if bestscore == None:
                  bestscore = solution.score()
                  finalsolution = solution
              elif self.minimize:
                  score = solution.score()
                  if score < bestscore:
                      bestscore = score
                      finalsolution = solution
              elif not self.minimize:
                  score = solution.score()
                  if score > bestscore:
                      bestscore = score
                      finalsolution = solution                
          return finalsolution
docs: Returns the single best result (if multiple have the same score, the first match is returned)