nodes: 0, module; 1, function_definition; 2, function_name:image_from_name; 3, parameters; 4, block; 5, identifier:name; 6, identifier:images; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, expression_statement; 11, return_statement; 12, comment:"""Return an image from a list of images.  If the name is an exact
      match, return the last exactly matching image.  Otherwise, sort
      images by 'natural' order, using decorate-sort-undecorate, and
      return the largest.
  
      see:
      http://code.activestate.com/recipes/285264-natural-string-sorting/
      """; 13, assignment; 14, comparison_operator:name in [i.name for i in prefixed_images]; 15, block; 16, assignment; 17, subscript; 18, identifier:prefixed_images; 19, list_comprehension; 20, identifier:name; 21, list_comprehension; 22, return_statement; 23, identifier:decorated; 24, call; 25, list_comprehension; 26, unary_operator; 27, identifier:i; 28, for_in_clause; 29, if_clause; 30, attribute; 31, for_in_clause; 32, subscript; 33, identifier:sorted; 34, argument_list; 35, subscript; 36, for_in_clause; 37, integer:1; 38, identifier:i; 39, identifier:images; 40, call; 41, identifier:i; 42, identifier:name; 43, identifier:i; 44, identifier:prefixed_images; 45, list_comprehension; 46, unary_operator; 47, list_comprehension; 48, identifier:i; 49, integer:1; 50, identifier:i; 51, identifier:decorated; 52, attribute; 53, argument_list; 54, identifier:i; 55, for_in_clause; 56, if_clause; 57, integer:1; 58, tuple; 59, for_in_clause; 60, attribute; 61, identifier:startswith; 62, identifier:name; 63, identifier:i; 64, identifier:prefixed_images; 65, comparison_operator:i.name == name; 66, call; 67, identifier:i; 68, identifier:i; 69, identifier:prefixed_images; 70, identifier:i; 71, identifier:name; 72, attribute; 73, identifier:name; 74, identifier:int; 75, argument_list; 76, identifier:i; 77, identifier:name; 78, call; 79, attribute; 80, argument_list; 81, call; 82, identifier:group; 83, integer:0; 84, attribute; 85, argument_list; 86, identifier:re; 87, identifier:search; 88, string; 89, attribute; 90, string_content; 91, identifier:i; 92, identifier:name
code: def image_from_name(name, images):
  
      """Return an image from a list of images.  If the name is an exact
      match, return the last exactly matching image.  Otherwise, sort
      images by 'natural' order, using decorate-sort-undecorate, and
      return the largest.
  
      see:
      http://code.activestate.com/recipes/285264-natural-string-sorting/
      """
  
      prefixed_images = [i for i in images if i.name.startswith(name)]
  
      if name in [i.name for i in prefixed_images]:
          return [i for i in prefixed_images if i.name == name][-1]
  
      decorated = sorted(
          [(int(re.search('\d+', i.name).group(0)), i) for i in prefixed_images])
      return [i[1] for i in decorated][-1]