Unregisters given :class:`umbra.components.factory.script_editor.nodes.DirectoryNode` class Node from the Model.

        :param directory_node: DirectoryNode to unregister.
        :type directory_node: DirectoryNode
        :param raise_exception: Raise the exception.
        :type raise_exception: bool
        :return: DirectoryNode.
        :rtype: DirectoryNode

def unregister_directory(self, directory_node, raise_exception=False):
        """
        Unregisters given :class:`umbra.components.factory.script_editor.nodes.DirectoryNode` class Node from the Model.

        :param directory_node: DirectoryNode to unregister.
        :type directory_node: DirectoryNode
        :param raise_exception: Raise the exception.
        :type raise_exception: bool
        :return: DirectoryNode.
        :rtype: DirectoryNode
        """

        if raise_exception:
            if not directory_node in self.list_directory_nodes():
                raise foundations.exceptions.ProgrammingError(
                    "{0} | '{1}' directory 'DirectoryNode' isn't registered!".format(
                        self.__class__.__name__, directory_node))

        LOGGER.debug("> Unregistering '{0}' directory 'DirectoryNode'.".format(directory_node))

        parent = directory_node.parent
        row = directory_node.row()
        self.beginRemoveRows(self.get_node_index(parent), row, row)
        parent.remove_child(row)
        self.endRemoveRows()

        self.directory_unregistered.emit(directory_node)

        return directory_node