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

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 .
