def PopulateTreeCtrl(self, ctx, tree=None, root_label="root", nodes=None):
        """populates a tree control with all the nodes with values in a context"""
        tree = tree or self._dag_tree

        # clear any previous data
        prev_data = tree.GetPyData(tree.GetRootItem())
        if prev_data:
            prev_ctx, prev_node = prev_data
            prev_node.clear(prev_ctx)

        root_ctx = ctx
        date = root_ctx.get_date()
        self._date_picker.SetValue(to_wxdate(date))
        self._last_selected_start_date = date

        # only enable the refresh button if date is a weekday
        self._toolbar.EnableTool(self.refreshId, date.weekday() <= 4)
        self._toolbar.Refresh()

        if nodes is None:
            head_nodes = {}
            for node, ctx in _get_head_nodes(ctx):
                head_nodes.setdefault(ctx, []).append(node)
        else:
            head_nodes = {ctx : list(nodes)}

        # clear the tree and add the new items
        tree.DeleteAllItems()

        root = tree.AddRoot(root_label, 0)
        for i in range(len(self._columns[:1])):
            tree.SetItemText(root, "", i+1)

        # make the root context dependent on the head nodes
        self._root_node.clear(root_ctx)
        for ctx, nodes in head_nodes.iteritems():
            for node in nodes:
                self._root_node.add_dependency(root_ctx, node, ctx)

        # evaluate the root node to mark it as not dirty
        root_ctx[self._root_node]

        tree.SetItemHasChildren(root, len(head_nodes) > 0)

        # and set the data for the root item
        tree.SetPyData(root, (root_ctx, self._root_node))

        # expand to show first level children
        tree.Expand(root)
dataset/ETHPy150Open manahl/mdf/mdf/viewer/frame.py/MDFViewerFrame.PopulateTreeCtrl/original