module RuboCop::Cop::Util

def first_part_of_call_chain(node)

with calls chained to the end of it.
Returns, for example, a bare `if` node if the given node is an `if`
def first_part_of_call_chain(node)
  while node
    case node.type
    when :send
      receiver, _method_name, _args = *node
      node = receiver
    when :block
      method, _args, _body = *node
      node = method
    else
      break
    end
  end
  node
end