code: def _find_longest_parent_path(path_set, path):
      """Finds the longest "parent-path" of 'path' in 'path_set'.
  
      This function takes and returns "path-like" strings which are strings
      made of strings separated by os.sep. No file access is performed here, so
      these strings need not correspond to actual files in some file-system..
      This function returns the longest ancestor path
      For example, for path_set=["/foo/bar", "/foo", "/bar/foo"] and
      path="/foo/bar/sub_dir", returns "/foo/bar".
  
      Args:
        path_set: set of path-like strings -- e.g. a list of strings separated by
          os.sep. No actual disk-access is performed here, so these need not
          correspond to actual files.
        path: a path-like string.
  
      Returns:
        The element in path_set which is the longest parent directory of 'path'.
      """
      # This could likely be more efficiently implemented with a trie
      # data-structure, but we don't want to add an extra dependency for that.
      while path not in path_set:
          if not path:
              return None
          path = os.path.dirname(path)
      return path
  
imports: import collections
  import os
  from tensorboard.data import provider
  from tensorboard.plugins.hparams import api_pb2
  from tensorboard.plugins.hparams import json_format_compat
  from tensorboard.plugins.hparams import metadata
  from google.protobuf import json_format
  from tensorboard.plugins.scalar import metadata
label_desc: Use image node_id 2 for calling a global function with example usage: _find_longest_parent_path(path_set, path) and returns: path, None