nodes: 0, module; 1, function_definition; 2, function_name:deep_merge_dict; 3, parameters; 4, block; 5, identifier:base; 6, identifier:priority; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, for_statement; 11, return_statement; 12, comment:"""Recursively merges the two given dicts into a single dict.
  
      Treating base as the the initial point of the resulting merged dict,
      and considering the nested dictionaries as trees, they are merged os:
      1. Every path to every leaf in priority would be represented in the result.
      2. Subtrees of base are overwritten if a leaf is found in the
      corresponding path in priority.
      3. The invariant that all priority leaf nodes remain leafs is maintained.
  
  
      Parameters
      ----------
      base : dict
          The first, lower-priority, dict to merge.
      priority : dict
          The second, higher-priority, dict to merge.
  
      Returns
      -------
      dict
          A recursive merge of the two given dicts.
  
      Example:
      --------
      >>> base = {'a': 1, 'b': 2, 'c': {'d': 4}, 'e': 5}
      >>> priority = {'a': {'g': 7}, 'c': 3, 'e': 5, 'f': 6}
      >>> result = deep_merge_dict(base, priority)
      >>> print(sorted(result.items()))
      [('a', {'g': 7}), ('b', 2), ('c', 3), ('e', 5), ('f', 6)]
      """; 13, boolean_operator; 14, block; 15, assignment; 16, identifier:key; 17, call; 18, block; 19, identifier:result; 20, not_operator; 21, not_operator; 22, return_statement; 23, identifier:result; 24, call; 25, attribute; 26, argument_list; 27, if_statement; 28, call; 29, call; 30, identifier:priority; 31, attribute; 32, argument_list; 33, identifier:priority; 34, identifier:keys; 35, comparison_operator:key in base; 36, block; 37, else_clause; 38, identifier:isinstance; 39, argument_list; 40, identifier:isinstance; 41, argument_list; 42, identifier:copy; 43, identifier:deepcopy; 44, identifier:base; 45, identifier:key; 46, identifier:base; 47, expression_statement; 48, block; 49, identifier:base; 50, identifier:dict; 51, identifier:priority; 52, identifier:dict; 53, assignment; 54, expression_statement; 55, subscript; 56, call; 57, assignment; 58, identifier:result; 59, identifier:key; 60, identifier:deep_merge_dict; 61, argument_list; 62, subscript; 63, subscript; 64, subscript; 65, subscript; 66, identifier:result; 67, identifier:key; 68, identifier:priority; 69, identifier:key; 70, identifier:base; 71, identifier:key; 72, identifier:priority; 73, identifier:key
code: def deep_merge_dict(base, priority):
      """Recursively merges the two given dicts into a single dict.
  
      Treating base as the the initial point of the resulting merged dict,
      and considering the nested dictionaries as trees, they are merged os:
      1. Every path to every leaf in priority would be represented in the result.
      2. Subtrees of base are overwritten if a leaf is found in the
      corresponding path in priority.
      3. The invariant that all priority leaf nodes remain leafs is maintained.
  
  
      Parameters
      ----------
      base : dict
          The first, lower-priority, dict to merge.
      priority : dict
          The second, higher-priority, dict to merge.
  
      Returns
      -------
      dict
          A recursive merge of the two given dicts.
  
      Example:
      --------
      >>> base = {'a': 1, 'b': 2, 'c': {'d': 4}, 'e': 5}
      >>> priority = {'a': {'g': 7}, 'c': 3, 'e': 5, 'f': 6}
      >>> result = deep_merge_dict(base, priority)
      >>> print(sorted(result.items()))
      [('a', {'g': 7}), ('b', 2), ('c', 3), ('e', 5), ('f', 6)]
      """
      if not isinstance(base, dict) or not isinstance(priority, dict):
          return priority
      result = copy.deepcopy(base)
      for key in priority.keys():
          if key in base:
              result[key] = deep_merge_dict(base[key], priority[key])
          else:
              result[key] = priority[key]
      return result