code: def rewrite_refs( targets, old,new, index, key='refs', single_ref=False ):
      
      for parent in targets:
          if not isinstance( parent, dict ):
              try:
                  parent = index[parent]
              except KeyError, err:
                  continue 
          rewrite_references( parent[key], old, new, single_ref=single_ref )
docs: Rewrite key in all targets (from index if necessary) to replace old with new