def METHOD_NAME(self):
    if self.path is None:
        return
    if not self.path.is_dir():
        return
    dirs_to_copy = self.load_settings()
    self.dirsTreeWidget.clear()
    def build_item_cb(item: QTreeWidgetItem, node: DirectoryTreeDict):
        relative_path = node["path"].relative_to(self.path)
        str_path = str(relative_path)
        # TODO decide whether or not to take into account the attachment_dirs into account
        # attachment_dirs = self.preferences.value("attachmentDirs") # TODO move this in the outer scope
        # matches = False
        # for attachment_dir in attachment_dirs:
        #     if str_path.startswith(attachment_dir):
        #         matches = True
        # if not matches:
        #     return False
        check_state = (
            Qt.Checked if dirs_to_copy.get(str_path, True) else Qt.Unchecked
        )
        item.setCheckState(0, check_state)
        item.setExpanded(True)
        item.setData(0, Qt.UserRole, str_path)
        item.setToolTip(0, str(node["path"].absolute()))
        item.setFlags(
            item.flags()
            | Qt.ItemIsUserCheckable
            | Qt.ItemIsSelectable
            | Qt.ItemIsAutoTristate
        )
    root_item = self.dirsTreeWidget.invisibleRootItem()
    dict_paths = path_to_dict(self.path, dirs_only=True)
    if dict_paths["type"] == DirectoryTreeType.DIRECTORY:
        for subnode in dict_paths["content"]:
            build_file_tree_widget_from_dict(
                root_item,
                subnode,
                build_item_cb,
            )