<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def __delete_directory(self, directory):
 """ Deletes given directory. :param directory: Directory to delete. :type directory: unicode """


        for node in itertools.chain(self.__script_editor.model.get_project_nodes(directory),
                                    self.__script_editor.model.get_directory_nodes(directory)):
            self.__script_editor.model.unregister_project_nodes(node)
            if node.family == "Directory":
                self.__script_editor.model.unregister_project_nodes(node)
                self.__script_editor.model.unregister_directory(node)
            elif node.family == "Project":
                self.__script_editor.remove_project(directory)
            self.__delete_path(directory)