def AddNodeToRoot(self, node, ctx=None):
        """
        Add an mdf node to the root node of the tree.
        If ctx is None the current root context is used.
        """
        assert isinstance(node, MDFNode), \
            "node must be an mdf node"

        tree = self._dag_tree
        root_item = tree.GetRootItem()

        # create a new context if there isn't one already
        data = tree.GetPyData(root_item)
        if data is None:
            root_ctx = ctx or MDFContext()
            self.SetContext(root_ctx, nodes=[])
            data = self.tree.GetPyData(root_item)
        root_ctx, root_node = data

        if ctx is None:
            ctx = root_ctx

        assert ctx.is_shift_of(root_ctx), \
            "ctx must either be the root context or a shift of the root context"

        # if the node has already been added don't add it again
        if (node, ctx) in root_node.get_dependencies(root_ctx):
            return

        root_node.add_dependency(root_ctx, node, ctx)
        tree.SetItemHasChildren(root_item, True)

        if tree.IsExpanded(root_item):
            image = self.NORMAL_FILE
            if node.get_dependencies(root_ctx):
                image = self.FOLDER
            last = tree.AppendItem(root_item, node.short_name, image)
            self._dag_tree.SetPyData(last, (ctx, node))
            self.RefreshItem(self._dag_tree, last)
        else:
            tree.Expand(root_item)
dataset/ETHPy150Open manahl/mdf/mdf/viewer/frame.py/MDFViewerFrame.AddNodeToRoot/original