class Mustache::Template

def section_names

def section_names
  def recursor(toks, section)
    sections = []
    toks.each do |token|
      next unless token.is_a? Array
      if token[0] == :mustache && [:section,:inverted_section].include? token[1]
        new_section = section + [token[2][2][0]]
        sections += [ new_section.join('.') ] + recursor(token[4], new_section)
      else
        sections += recursor(token, section)
      end
    end
    sections
  end
  recursor(tokens,[]).reject(&:nil?).uniq
end