code: def remove_unused_links(dirpath, required_links):
      
      for root, dirs, files in os.walk(dirpath):
        for p in chain(dirs, files):
          p = os.path.join(root, p)
          if os.path.islink(p) and p not in required_links:
            os.unlink(p)
docs: Recursively remove any links in dirpath which are not contained in required_links.
  
      :param str dirpath: Absolute path of directory to search.
      :param container required_links: Container of "in use" links which should not be removed,
                                       where each link is an absolute path.