class Rubocop::Cop::Style::BlockNesting

def check_nesting_level(node, max, current_level)

def check_nesting_level(node, max, current_level)
  if NESTING_BLOCKS.include?(node.type)
    unless node.loc.respond_to?(:keyword) &&
        node.loc.keyword.is?('elsif')
      current_level += 1
    end
    if current_level == max + 1
      add_offense(node, :expression, message(max)) do
        self.max = current_level
      end
      return
    end
  end
  node.children.each do |child|
    if child.is_a?(Parser::AST::Node)
      check_nesting_level(child, max, current_level)
    end
  end
end