code: def _ancestry(path):
      """
      Given a path with elements separated by
      posixpath.sep, generate all elements of that path
  
      >>> list(_ancestry('b/d'))
      ['b/d', 'b']
      >>> list(_ancestry('/b/d/'))
      ['/b/d', '/b']
      >>> list(_ancestry('b/d/f/'))
      ['b/d/f', 'b/d', 'b']
      >>> list(_ancestry('b'))
      ['b']
      >>> list(_ancestry(''))
      []
      """
      path = path.rstrip(posixpath.sep)
      while path and path != posixpath.sep:
          yield path
          path, tail = posixpath.split(path)
  
imports: import io
  import posixpath
  import zipfile
  import itertools
  import contextlib
  import pathlib
  import re
  from .glob import translate
label_desc: Use image node_id 2 for calling a global function with example usage: _ancestry(path) without return types