code: def cull_prefixes(graph, prefixes={k:v for k, v in uPREFIXES.items() if k != 'NIFTTL'},
                    cleanup=lambda ps, graph: None, keep=False):
      
      prefs = ['']
      if keep:
          prefixes.update({p:str(n) for p, n in graph.namespaces()})
  
      if '' not in prefixes:
          prefixes[''] = null_prefix  # null prefix
  
      pi = {v:k for k, v in prefixes.items()}
      asdf = {} #{v:k for k, v in ps.items()}
      asdf.update(pi)
      # determine which prefixes we need
      for uri in set((e for t in graph for e in t)):
          if uri.endswith('.owl') or uri.endswith('.ttl') or uri.endswith('$$ID$$'):
              continue  # don't prefix imports or templates
          for rn, rp in sorted(asdf.items(), key=lambda a: -len(a[0])):  # make sure we get longest first
              lrn = len(rn)
              if type(uri) == rdflib.BNode:
                  continue
              elif uri.startswith(rn) and '#' not in uri[lrn:] and '/' not in uri[lrn:]:  # prevent prefixing when there is another sep
                  prefs.append(rp)
                  break
  
      ps = {p:prefixes[p] for p in prefs}
  
      cleanup(ps, graph)
  
      ng = makeGraph('', prefixes=ps)
      [ng.g.add(t) for t in graph]
      return ng
docs: Remove unused curie prefixes and normalize to a standard set.