Return a pygit2.Tree object matching a SHA

def get_tree_from_sha(self, ref):
        '''
        Return a pygit2.Tree object matching a SHA
        '''
        try:
            return self.repo.revparse_single(ref).tree
        except (KeyError, TypeError, ValueError, AttributeError):
            return None