def get_tree(self, tgt_env):
        '''
        Return a pygit2.Tree object if the branch/tag/SHA is found, otherwise
        None
        '''
        if tgt_env == 'base':
            tgt_ref = self.base
        else:
            tgt_ref = tgt_env
        for ref in self.repo.listall_references():
            _, rtype, rspec = ref.split('/', 2)
            if rtype in ('remotes', 'tags'):
                parted = rspec.partition('/')
                rspec = parted[2] if parted[2] else parted[0]
                if rspec == tgt_ref and self.env_is_exposed(tgt_env):
                    return self.repo.lookup_reference(ref).get_object().tree

        # Branch or tag not matched, check if 'tgt_env' is a commit
        if not self.env_is_exposed(tgt_env):
            return None
        try:
            commit = self.repo.revparse_single(tgt_ref)
        except (__HOLE__, TypeError):
            # Not a valid commit, likely not a commit SHA
            pass
        else:
            return commit.tree
        return None
dataset/ETHPy150Open saltstack/salt/salt/utils/gitfs.py/Pygit2.get_tree