code: def commuting_sets_by_zbasis(pauli_sums):
      
      diagonal_sets = {}
      for term in pauli_sums:
          diagonal_sets = _max_key_overlap(term, diagonal_sets)
  
      return diagonal_sets
docs: Computes commuting sets based on terms having the same diagonal basis
  
      Following the technique outlined in the appendix of arXiv:1704.05018.
  
      :param pauli_sums: PauliSum object to group
      :return: dictionary where key value pair is a tuple corresponding to the
               basis and a list of PauliTerms associated with that basis.