<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def search(self, pattern, **kwargs):
 """ Searchs given pattern text in the document. Usage:: True True backward_search=True, wrap_around=True) True :param pattern: Pattern to search for. :type pattern: unicode :param \*\*kwargs: Search settings. :type \*\*kwargs: dict :return: Method success. :rtype: bool """


        settings = foundations.data_structures.Structure(**{"case_sensitive": False,
                                                            "whole_word": False,
                                                            "regular_expressions": False,
                                                            "backward_search": False,
                                                            "wrap_around": True})
        settings.update(kwargs)

        self.__search_pattern = pattern

        if settings.regular_expressions:
            pattern = QRegExp(pattern)
            pattern.setCaseSensitivity(Qt.CaseSensitive if settings.case_sensitive else Qt.CaseInsensitive)

        flags = QTextDocument.FindFlags()
        if settings.case_sensitive:
            flags = flags | QTextDocument.FindCaseSensitively
        if settings.whole_word:
            flags = flags | QTextDocument.FindWholeWords
        if settings.backward_search:
            flags = flags | QTextDocument.FindBackward

        cursor = self.document().find(pattern, self.textCursor(), flags)
        if not cursor.isNull():
            self.setTextCursor(cursor)
            return True
        else:
            if settings.wrap_around:
                self.store_text_cursor_anchor()
                cursor = self.textCursor()
                if settings.backward_search:
                    cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor)
                else:
                    cursor.movePosition(QTextCursor.Start, QTextCursor.MoveAnchor)
                self.setTextCursor(cursor)
                settings.wrap_around = False
                if self.search(pattern, **settings):
                    return True
                else:
                    self.restore_text_cursor_anchor()