docs: def destination_heuristic(data):
      """
      A heuristic to get the folder with all other files from bib, using majority
      vote.
      """
      counter = collections.Counter()
      for entry in data:
          file_field = entry['fields'].get('file')
          if not file_field:
              continue
          path = os.path.dirname(file_field)
          counter[path] += 1
  
      if not counter:  # No paths found
          raise click.ClickException(
              'Path finding heuristics failed: no paths in the database'
          )
  
      # Find the paths that appears most often
      sorted_paths = sorted(counter, reverse=True)
      groupby = itertools.groupby(sorted_paths, key=len)
      _, group = next(groupby)
  
      # We know that there's at least one candidate. Make sure it's
      # the only one
      candidate = next(group)
      try:
          next(group)
      except StopIteration:
          return candidate
      else:
          raise click.ClickException(
              'Path finding heuristics failed: '
              'there are multiple equally valid paths in the database'
          )