def get_object_from_path(repo, tree, path):
    path_segments = path.split("/")

    ctree = tree
    for i, path_seg in enumerate(path_segments):
        if ctree.type != GIT_OBJ_TREE:
            raise NotFound("invalid path; traversal unexpectedly encountered a non-tree")
        if not path_seg and i == len(path_segments) - 1:  # allow trailing slash in paths to directories
            continue
        try:
            ctree = repo[ctree[path_seg].id]
        except __HOLE__:
            raise NotFound("invalid path; no such object")
    return ctree
dataset/ETHPy150Open hulu/restfulgit/restfulgit/porcelain/retrieval.py/get_object_from_path