nodes: 0, module; 1, function_definition; 2, function_name:union; 3, parameters; 4, block; 5, identifier:self; 6, list_splat_pattern; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, expression_statement; 13, return_statement; 14, identifier:others; 15, comment:r"""Return a new multiset with all elements from the multiset and the others with maximal multiplicities.
  
          >>> ms = Multiset('aab')
          >>> sorted(ms.union('bc'))
          ['a', 'a', 'b', 'c']
  
          You can also use the ``|`` operator for the same effect. However, the operator version
          will only accept a set as other operator, not any iterable, to avoid errors.
  
          >>> ms = Multiset('aab')
          >>> sorted(ms | Multiset('aaa'))
          ['a', 'a', 'a', 'b']
  
          For a variant of the operation which modifies the multiset in place see
          :meth:`union_update`.
  
          Args:
              *others: The other sets to union the multiset with. Can also be any :class:`~typing.Iterable`\[~T]
                  or :class:`~typing.Mapping`\[~T, :class:`int`] which are then converted to :class:`Multiset`\[~T].
  
          Returns:
              The multiset resulting from the union.
          """; 16, assignment; 17, assignment; 18, assignment; 19, identifier:other; 20, call; 21, block; 22, assignment; 23, identifier:result; 24, identifier:result; 25, call; 26, identifier:_elements; 27, attribute; 28, identifier:_total; 29, attribute; 30, identifier:map; 31, argument_list; 32, for_statement; 33, attribute; 34, identifier:_total; 35, attribute; 36, argument_list; 37, identifier:result; 38, identifier:_elements; 39, identifier:result; 40, identifier:_total; 41, attribute; 42, identifier:others; 43, pattern_list; 44, call; 45, block; 46, identifier:result; 47, identifier:_total; 48, identifier:self; 49, identifier:__copy__; 50, identifier:self; 51, identifier:_as_mapping; 52, identifier:element; 53, identifier:multiplicity; 54, attribute; 55, argument_list; 56, expression_statement; 57, if_statement; 58, identifier:other; 59, identifier:items; 60, assignment; 61, comparison_operator:multiplicity > old_multiplicity; 62, block; 63, identifier:old_multiplicity; 64, call; 65, identifier:multiplicity; 66, identifier:old_multiplicity; 67, expression_statement; 68, expression_statement; 69, attribute; 70, argument_list; 71, assignment; 72, augmented_assignment; 73, identifier:_elements; 74, identifier:get; 75, identifier:element; 76, integer:0; 77, subscript; 78, identifier:multiplicity; 79, identifier:_total; 80, binary_operator:multiplicity - old_multiplicity; 81, identifier:_elements; 82, identifier:element; 83, identifier:multiplicity; 84, identifier:old_multiplicity
code: def union(self, *others):
          r"""Return a new multiset with all elements from the multiset and the others with maximal multiplicities.
  
          >>> ms = Multiset('aab')
          >>> sorted(ms.union('bc'))
          ['a', 'a', 'b', 'c']
  
          You can also use the ``|`` operator for the same effect. However, the operator version
          will only accept a set as other operator, not any iterable, to avoid errors.
  
          >>> ms = Multiset('aab')
          >>> sorted(ms | Multiset('aaa'))
          ['a', 'a', 'a', 'b']
  
          For a variant of the operation which modifies the multiset in place see
          :meth:`union_update`.
  
          Args:
              *others: The other sets to union the multiset with. Can also be any :class:`~typing.Iterable`\[~T]
                  or :class:`~typing.Mapping`\[~T, :class:`int`] which are then converted to :class:`Multiset`\[~T].
  
          Returns:
              The multiset resulting from the union.
          """
          result = self.__copy__()
          _elements = result._elements
          _total = result._total
          for other in map(self._as_mapping, others):
              for element, multiplicity in other.items():
                  old_multiplicity = _elements.get(element, 0)
                  if multiplicity > old_multiplicity:
                      _elements[element] = multiplicity
                      _total += multiplicity - old_multiplicity
          result._total = _total
          return result