DefaultMutableTreeNode root = (DefaultMutableTreeNode) tm.getRoot();
    private void buildTreeNode(ImageDisplay node)    {        DefaultMutableTreeNode dtn;        DefaultTreeModel tm = (DefaultTreeModel) getModel();        dtn = (DefaultMutableTreeNode) identityMap.get(node);        if (dtn == null) { // create a tree node            dtn = new DefaultMutableTreeNode(node);            identityMap.put(node, dtn);        }        ImageDisplay parent = node.getParentDisplay();        DefaultMutableTreeNode root = (DefaultMutableTreeNode) tm.getRoot();        if (parent.getParentDisplay() == null) { //i.e. the parent is root            if (!(hasBeenAdded(dtn, root)))                tm.insertNodeInto(dtn, root, root.getChildCount());        } else {            DefaultMutableTreeNode                 pdtn = (DefaultMutableTreeNode) identityMap.get(parent);            if (pdtn == null) { // create a tree node                pdtn = new DefaultMutableTreeNode(parent);                identityMap.put(parent, pdtn);            }            if (!(hasBeenAdded(dtn, pdtn)))                tm.insertNodeInto(dtn, pdtn, pdtn.getChildCount());            buildTreeNode(parent);        }       }