nodes: 0, module; 1, function_definition; 2, function_name:add_cohp_dict; 3, parameters; 4, block; 5, identifier:self; 6, identifier:cohp_dict; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, for_statement; 11, identifier:key_sort_func; 12, None; 13, comment:"""
          Adds a dictionary of COHPs with an optional sorting function
          for the keys.
  
          Args:
              cohp_dict: dict of the form {label: Cohp}
  
              key_sort_func: function used to sort the cohp_dict keys.
          """; 14, identifier:key_sort_func; 15, block; 16, else_clause; 17, identifier:label; 18, identifier:keys; 19, block; 20, expression_statement; 21, block; 22, expression_statement; 23, assignment; 24, expression_statement; 25, call; 26, identifier:keys; 27, call; 28, assignment; 29, attribute; 30, argument_list; 31, identifier:sorted; 32, argument_list; 33, identifier:keys; 34, call; 35, identifier:self; 36, identifier:add_cohp; 37, identifier:label; 38, subscript; 39, call; 40, keyword_argument; 41, attribute; 42, argument_list; 43, identifier:cohp_dict; 44, identifier:label; 45, attribute; 46, argument_list; 47, identifier:key; 48, identifier:key_sort_func; 49, identifier:cohp_dict; 50, identifier:keys; 51, identifier:cohp_dict; 52, identifier:keys
code: def add_cohp_dict(self, cohp_dict, key_sort_func=None):
          """
          Adds a dictionary of COHPs with an optional sorting function
          for the keys.
  
          Args:
              cohp_dict: dict of the form {label: Cohp}
  
              key_sort_func: function used to sort the cohp_dict keys.
          """
          if key_sort_func:
              keys = sorted(cohp_dict.keys(), key=key_sort_func)
          else:
              keys = cohp_dict.keys()
          for label in keys:
              self.add_cohp(label, cohp_dict[label])