def each_ancestor(*types, &block)
      return to_enum(__method__, *types) unless block_given?

      types.flatten!

      if types.empty?
        visit_ancestors(&block)
      else
        visit_ancestors_with_types(types, &block)
      end

      self
    end
def each_ancestor(*types, &block)
      return to_enum(__method__, *types) unless block_given?

      types.flatten!

      if types.empty?
        visit_ancestors(&block)
      else
        visit_ancestors_with_types(types, &block)
      end

      self
    end
Calls the given block for each ancestor node in the order from parent to root.
 If no block is given, an `Enumerator` is returned.

 @overload each_ancestor
   Yield all nodes.
 @overload each_ancestor(type)
   Yield only nodes matching the type.
   @param [Symbol] type a node type
 @overload each_ancestor(type_a, type_b, ...)
   Yield only nodes matching any of the types.
   @param [Symbol] type_a a node type
   @param [Symbol] type_b a node type
 @overload each_ancestor(types)
   Yield only nodes matching any of types in the array.
   @param [Array<Symbol>] types an array containing node types
 @yieldparam [Node] node each ancestor node
 @return [self] if a block is given
 @return [Enumerator] if no block is given