code: def discover_base_dir(start_dir):
      '''Return start_dir or the parent dir that has the s2 marker.
  
      Starting from the specified directory, and going up the parent
      chain, check each directory to see if it's a base_dir (contains
      the "marker" directory *s2*) and return it. Otherwise, return
      the start_dir.
  
      '''
      if is_base_dir(start_dir):
          return start_dir
      pcl = start_dir.split('/')  #path component list
      found_base_dir = None
      for i in range(1, len(pcl)+1):
          d2c = '/'.join(pcl[:-i])
          if (d2c == ''):
              d2c = '/'
          if is_base_dir(d2c):
              found_base_dir = d2c
              break
      return found_base_dif discover_base_dir(start_dir):
      '''Return start_dir or the parent dir that has the s2 marker.
  
      Starting from the specified directory, and going up the parent
      chain, check each directory to see if it's a base_dir (contains
      the "marker" directory *s2*) and return it. Otherwise, return
      the start_dir.
  
      '''
      if is_base_dir(start_dir):
          return start_dir
      pcl = start_dir.split('/')  #path component list
      found_base_dir = None
      for i in range(1, len(pcl)+1):
          d2c = '/'.join(pcl[:-i])
          if (d2c == ''):
              d2c = '/'
          if is_base_dir(d2c):
              found_base_dir = d2c
              break
      return found_base_dir
docs: Return start_dir or the parent dir that has the s2 marker.
  
      Starting from the specified directory, and going up the parent
      chain, check each directory to see if it's a base_dir (contains
      the "marker" directory *s2*) and return it. Otherwise, return
      the start_dir.