public static boolean isAncestor(final TreeNode node, final TreeNode parent) {
    if (parent == node) {
      return true;
    }

    for (int i = 0; i < parent.getChildCount(); i++) {
      if (isAncestor(node, parent.getChildAt(i))) {
        return true;
      }
    }

    return false;
  }
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