code: def tree_lookup(self, target_path, commit):
          
          segments = target_path.split("/")
          tree_or_blob = commit.tree
          path = ''
          while segments:
              dirent = segments.pop(0)
              if isinstance(tree_or_blob, pygit2.Tree):
                  if dirent in tree_or_blob:
                      tree_or_blob = self.repo[tree_or_blob[dirent].oid]
                      # self.logger.debug("  %s in %s" % (dirent, path))
                      if path:
                          path += '/'
                      path += dirent
                  else:
                      # This is probably because we were called on a
                      # commit whose parent added a new directory.
                      self.logger.debug("        %s not in %s in %s" %
                                        (dirent, path, commit.hex[:8]))
                      return None
              else:
                  self.logger.debug("        %s not a tree in %s" %
                                    (tree_or_blob, commit.hex[:8]))
                  return None
          return tree_or_blob
docs: Navigate to the tree or blob object pointed to by the given target
          path for the given commit.  This is necessary because each git
          tree only contains entries for the directory it refers to, not
          recursively for all subdirectories.