code: def remove_duplicates(seq, idfun=None):
      
      # order preserving
      if idfun is None:
  
          def idfun(x):
              return x
  
      seen = {}
      result = []
      for item in seq:
          marker = idfun(item)
          # in old Python versions:
          # if seen.has_key(marker)
          # but in new ones:
          if marker in seen: continue
          seen[marker] = 1
          result.append(item)
      return result
docs: removes duplicates from a list, order preserving, as found in
      http://www.peterbe.com/plog/uniqifiers-benchmark