def get_tree(self, tgt_env):
        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 (KeyError, TypeError):
            # Not a valid commit, likely not a commit SHA
            pass
        else:
            return commit.tree
        return None
Determine the number of lines and columns visible in the terminal.
dataset/ETHPy150Open saltstack/salt/salt/utils/gitfs.py/Pygit2.get_tree--crossover with--dataset/ETHPy150Open xolox/python-humanfriendly/humanfriendly/terminal.py/find_terminal_size