code: def _theorem6p1():
      
  
      pruning_set = set()
  
      def _prune(x):
          if len(x) <= 2:
              return False
          # this is faster than tuple(x[-3:])
          key = (tuple(x[:-2]), x[-2], x[-1])
          return key in pruning_set
  
      def _explored(x):
          if len(x) >= 3:
              prunable = (tuple(x[:-2]), x[-1], x[-2])
              pruning_set.add(prunable)
  
      return _prune, _explored
docs: See Theorem 6.1 in paper.