public static void restoreExpansionState(
      final JTree tree, final int row, final String expansionState) {
    final StringTokenizer stok = new StringTokenizer(expansionState, ",");

    while (stok.hasMoreTokens()) {
      final int token = row + Integer.parseInt(stok.nextToken());
      tree.expandRow(token);
    }
  }
Tests whether a given node is an ancestor node of another node.

@param node The node to search for.
@param parent The parent node where the search begins.
@return True, if the node is an ancestor of parent. False, otherwise.
java/zylib/src/main/java/com/google/security/zynamics/zylib/gui/jtree/TreeHelpers.java