code: def search_for_most_recent_ancestor(
      repo: "git.Repo",
  ) -> Optional["git.Commit"]:
      most_recent_ancestor: Optional["git.Commit"] = None
  
      try:
          from git.exc import GitCommandError
  
          try:
              for branch in repo.heads:
                  tracking_branch = branch.tracking_branch()
                  if tracking_branch:
                      for ancestor in repo.merge_base(
                          repo.head, tracking_branch.commit
                      ):
                          if (
                              not most_recent_ancestor
                              or repo.is_ancestor(
                                  most_recent_ancestor, ancestor
                              )
                          ):
                              most_recent_ancestor = ancestor
          except GitCommandError:
              pass
      except ImportError:
          return None
  
      return most_recent_ancestor
  
file_path: neptune-client/src/neptune/internal/utils/git.py
imports: import logging
  import warnings
  from dataclasses import dataclass
  from datetime import datetime
  from typing import TYPE_CHECKING, List, Optional, Union
  from neptune.attributes.constants import DIFF_HEAD_INDEX_PATH, UPSTREAM_INDEX_DIFF
  from neptune.types import File
  from neptune.types.atoms.git_ref import GitRef, GitRefDisabled
label_desc: Use image node_id 6 for calling a global function with example usage: search_for_most_recent_ancestor(repo) and returns: most_recent_ancestor, None