<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def lookup_thread_id(self):
 """Lookup thread id as required by CommentThread.lookup_thread_id. This implementation will query GitHub with the required parameters to try and find the topic for the owner, realm, topic, etc., specified in init. """


        query_string = 'in:title "%s" repo:%s/%s' % (
            self.topic, self.owner, self.realm)
        cache_key = (self.owner, self.realm, self.topic)
        result = self.lookup_cache_key(cache_key)
        if result is not None:
            my_req = self.raw_pull(result)
            if my_req.status_code != 200:
                result = None  # Cached item was no good
            elif my_req.json()['title'] != self.topic:
                logging.debug('Title must have changed; ignore cache')
                result = None
            else:
                logging.debug('Using cached thread id %s for %s', str(result),
                              str(cache_key))
                return result
        data, dummy_hdr = self.raw_search(self.user, self.token, query_string)

        if data['total_count'] == 1:   # unique match
            if data['items'][0]['title'] == self.topic:
                result = data['items'][0]['number']
            else:
                result = None
        elif data['total_count'] > 1:  # multiple matches since github doesn't
            searched_data = [          # have unique search we must filter
                item for item in data['items'] if item['title'] == self.topic]
            if not searched_data:  # no matches
                return None
            elif len(searched_data) > 1:
                raise yap_exceptions.UnableToFindUniqueTopic(
                    self.topic, data['total_count'], '')
            else:
                assert len(searched_data) == 1, (
                    'Confused searching for topic "%s"' % str(self.topic))
                result = searched_data[0]['number']
        else:
            result = None
        self.update_cache_key(cache_key, result)

        return result