code: def _check_predecessor_successor_consistency(self):
          
          # Check 3.1: ensure that predecessors has the same headsets
          # that successors has
          predecessor_heads = set(self._predecessors.keys())
          successor_heads = set()
          for key, value in self._successors.items():
              successor_heads |= set(value.keys())
          if predecessor_heads != successor_heads:
              raise ValueError(
                  'Consistency Check 3.1 Failed: successors and predecessors ' +
                  'do not contain the same head sets \n' +
                  'predecessor heads: %s \n' % (predecessor_heads) +
                  'successor heads: %s' % (successor_heads))
  
          # Check 3.2: ensure that predecessors has the same tailsets
          # that successors has
          predecessor_tails = set()
          successor_tails = set(self._successors.keys())
          for key, value in self._predecessors.items():
              predecessor_tails |= set(value.keys())
          if successor_tails != predecessor_tails:
              raise ValueError(
                  'Consistency Check 3.2 Failed: successors and predecessors ' +
                  'do not contain the same tail sets \n' +
                  'predecessor tails: %s \n' % (predecessor_tails) +
                  'successor tails: %s' % (successor_tails))
  
          # Check 3.3: iterate through predecessors; check successor
          # symmetry
          for headset in self._predecessors.keys():
              for tailset in self._predecessors[headset].keys():
                  if self._predecessors[headset][tailset] != \
                          self._successors[tailset][headset]:
                      raise ValueError(
                          'Consistency Check 3.3 Failed: ' +
                          'headset = %s, ' % headset +
                          'tailset = %s, ' % tailset +
                          'but predecessors[headset][tailset] = ' +
                          '%s ' % self._predecessors[headset][tailset] +
                          'and successors[tailset][headset] = ' +
                          '%s ' % self._successors[tailset][headset])
docs: Consistency Check 3: predecessor/successor symmetry
  
          :raises: ValueError -- detected inconsistency among dictionaries