/**
   * Finds and returns the last leaf that is a descendant of this node -- either this node or its
   * last child's last leaf. Returns this node if it is a leaf.
   *
   * @see #isLeaf
   * @see #isNodeDescendant
   * @return the last leaf in the subtree rooted at this node
   */
  public DefaultMutableTreeNode getLastLeaf() {
    DefaultMutableTreeNode node = this;

    while (!node.isLeaf()) {
      node = (DefaultMutableTreeNode) node.getLastChild();
    }

    return node;
  }