// required by TreeSelectionListener interface
  public void valueChanged(TreeSelectionEvent e) {

    // get selected node
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getPath().getLastPathComponent();

    if (node == null) return;

    // get node data object
    TermNode nodeInfo = (TermNode) node.getUserObject();
    // load children only for leaf nodes and those that have
    // not been marked as processed.
    if (node.isLeaf() && node.getAllowsChildren()) {
      System.out.println("will load children for: " + nodeInfo);
      // load children. if no children, set allowsChildren to false
      if (!parent.loadChildren(node, nodeInfo.getTermId())) {
        node.setAllowsChildren(false);
      }
    }
    // loadmetadata
    System.out.println("will load metadata for: " + nodeInfo.getTermId());
    // call method on parent container
    parent.loadMetaData(nodeInfo.getTermId());
  }