code: private static boolean nodeHasAncestor(Node node, Node possibleAncestor) {
      // Note node is not in node.getAncestors()
  
      for (Node ancestor : node.getAncestors()) {
        if (ancestor == possibleAncestor) {
          return true;
        }
      }
  
      return false;
    }
docs: Returns true if {@code possibleAncestor} is an ancestor of{@code node}.
  A node is not considered to be an ancestor of itself.