code: def prune_dupes(self):
          
          n = 0
          pruned1 = []
          seen = set()
          deletes = {}
          for r in reversed(self.resources):
              if (r.uri in seen):
                  n += 1
                  if (r.uri in deletes):
                      deletes[r.uri] = r.change
              else:
                  pruned1.append(r)
                  seen.add(r.uri)
                  if (r.change == 'deleted'):
                      deletes[r.uri] = r.change
          # go through all deletes and prune if first was create
          pruned2 = []
          for r in reversed(pruned1):
              if (r.uri in deletes and deletes[r.uri] == 'created'):
                  n += 1
              else:
                  pruned2.append(r)
          self.resources = pruned2
          return(n)
docs: Remove all but the last entry for a given resource URI.
  
          Returns the number of entries removed. Also removes all entries for a
          given URI where the first entry is a create and the last entry is a
          delete.