creates a script sequence based on the script iterator type selected and the selected scripts and sends it to the tree
        self.tree_loaded

def add_script_sequence(self):
        """
        creates a script sequence based on the script iterator type selected and the selected scripts and sends it to the tree
        self.tree_loaded

        """

        def empty_tree(tree_model):
            # COMMENT_ME
            def add_children_to_list(item, somelist):
                if item.hasChildren():
                    for rownum in range(0, item.rowCount()):
                        somelist.append(str(item.child(rownum, 0).text()))

            output_list = []
            root = tree_model.invisibleRootItem()
            add_children_to_list(root, output_list)
            tree_model.clear()
            return output_list

        name = str(self.txt_script_sequence_name.text())
        new_script_list = empty_tree(self.tree_script_sequence_model)
        new_script_dict = {}
        for script in new_script_list:
            if script in self.elements_old:
                new_script_dict.update({script: self.elements_old[script]})
            elif script in self.elements_from_file:
                new_script_dict.update({script: self.elements_from_file[script]})

        new_script_parameter_dict = {}
        for index, script in enumerate(new_script_list):
            new_script_parameter_dict.update({script: index})
        # QtGui.QTextEdit.toPlainText()


        # get the module of the current dialogue

        package = get_python_package(inspect.getmodule(self).__file__)

        assert package is not None # check that we actually find a module

        # class_name = Script.set_up_dynamic_script(factory_scripts, new_script_parameter_list, self.cmb_looping_variable.currentText() == 'Parameter Sweep')
        new_script_dict = {name: {'class': 'ScriptIterator', 'package': package, 'scripts': new_script_dict,
                                  'info': str(self.txt_info.toPlainText()),
                                  'settings': {'script_order': new_script_parameter_dict,
                                               'iterator_type': str(self.cmb_looping_variable.currentText())}}}
        self.selected_element_name = name
        self.fill_tree(self.tree_loaded, new_script_dict)
        self.elements_from_file.update(new_script_dict)