class RuboCop::AST::ConstNode

def each_path(&block)

s(:const, s(:const, :Foo), :Bar)
s(:const, :Foo), then
s(:cbase), then
For `::Foo::Bar::BAZ` => yields:

Yield nodes for the namespace
def each_path(&block)
  return to_enum(__method__) unless block
  descendants = []
  last = self
  loop do
    last = last.children.first
    break if last.nil?
    descendants << last
    break unless last.const_type?
  end
  descendants.reverse_each(&block)
  self
end