code: def resolve_nested_dir(
      path: pathlib.Path, root: pathlib.Path
  ) -> pathlib.Path:
      """Returns the path that exists, out of foo/... and foo/foo/..., with root."""
      nested = path.parts[0] / path
      if (root_path := root / path).exists():
          return root_path
      elif (root_nested_path := root / nested).exists():
          return root_nested_path
      raise ValueError(f"Could not find {path} or {nested}")
  
file_path: tensorflow/tensorflow/lite/g3doc/tools/build_java_api_docs.py
imports: import os
  import pathlib
  import shutil
  import tempfile
  from typing import Iterable, Union
  from absl import app
  from absl import flags
  from tensorflow_docs.api_generator import gen_java
label_desc: Use image node_id 2 for calling a global function with example usage: resolve_nested_dir(path, root) and returns: root_path, root_nested_path