def METHOD_NAME(self, path, ref):
    comm, ref = self.repo.resolve_refish(ref or self.ref)
    parts = path.split("/")
    tree = comm.tree
    for part in parts:
        if part and isinstance(tree, pygit2.Tree):
            tree = tree[part]
    return tree