nodes: 0, module; 1, function_definition; 2, function_name:_find_best_fit; 3, parameters; 4, block; 5, identifier:self; 6, identifier:pbin; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, try_statement; 11, comment:"""
          Return best fitness rectangle from rectangles packing _sorted_rect list
  
          Arguments:
              pbin (PackingAlgorithm): Packing bin
  
          Returns:
              key of the rectangle with best fitness
          """; 12, assignment; 13, assignment; 14, block; 15, except_clause; 16, identifier:fit; 17, generator_expression; 18, identifier:fit; 19, generator_expression; 20, expression_statement; 21, return_statement; 22, identifier:ValueError; 23, block; 24, tuple; 25, for_in_clause; 26, identifier:f; 27, for_in_clause; 28, if_clause; 29, assignment; 30, identifier:rect; 31, return_statement; 32, call; 33, identifier:k; 34, pattern_list; 35, call; 36, identifier:f; 37, identifier:fit; 38, comparison_operator:f[0] is not None; 39, pattern_list; 40, call; 41, None; 42, attribute; 43, argument_list; 44, identifier:k; 45, identifier:r; 46, attribute; 47, argument_list; 48, subscript; 49, None; 50, identifier:_; 51, identifier:rect; 52, identifier:min; 53, argument_list; 54, identifier:pbin; 55, identifier:fitness; 56, subscript; 57, subscript; 58, attribute; 59, identifier:items; 60, identifier:f; 61, integer:0; 62, identifier:fit; 63, keyword_argument; 64, identifier:r; 65, integer:0; 66, identifier:r; 67, integer:1; 68, identifier:self; 69, identifier:_sorted_rect; 70, identifier:key; 71, attribute; 72, identifier:self; 73, identifier:first_item
code: def _find_best_fit(self, pbin):
          """
          Return best fitness rectangle from rectangles packing _sorted_rect list
  
          Arguments:
              pbin (PackingAlgorithm): Packing bin
  
          Returns:
              key of the rectangle with best fitness
          """
          fit = ((pbin.fitness(r[0], r[1]), k) for k, r in self._sorted_rect.items())
          fit = (f for f in fit if f[0] is not None)
          try:
              _, rect = min(fit, key=self.first_item)
              return rect
          except ValueError:
              return None