<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_format(self, name):
 """ Returns the closest format or closest parent format associated to given name. :param name: Format name. :type name: unicode :return: Format. :rtype: QTextCharFormat """


        formats = [format for format in self.list_formats(self.__root_node) if format in name]
        if not formats:
            return QTextCharFormat()

        name = max(formats)

        format = None
        current_node = self.__root_node
        for selector in name.split("."):
            nodes = [node for node in current_node.children if node.name == selector]
            format_node = nodes and nodes[0] or None
            if not format_node:
                break

            current_node = format_node

            if not format_node.format:
                continue

            format = format_node.format
        return format