code: public PlanNode findAncestor( Set<Type> typesToFind ) {
          PlanNode node = this;
          PlanNode parent = null;
          while ((parent = node.getParent()) != null) {
              if (typesToFind.contains(parent.getType())) return parent;
              node = parent;
          }
          return null;
      }
docs: Starting at the parent of this node, find the lowest (also closest) ancestor that has one of the specified types.
  
  @param typesToFind the set of types to find; may not be null
  @return the node with one of the specified types, or null if there is no such ancestor