global

def self.define_predicate(name, child_index: nil)

def self.define_predicate(name, child_index: nil)
  define_method(name) do
    target_node = control_node.children[child_index]
    # We don't use Kernel#Array here
    # because it invokes Node#to_a rather than wrapping with an array.
    if target_node.is_a?(Array)
      target_node.any? { |node| node.equal?(child_node) }
    else
      target_node.equal?(child_node)
    end
  end
end