code: def convert_to_match_query(ir_blocks):
      
      output_block = ir_blocks[-1]
      if not isinstance(output_block, ConstructResult):
          raise AssertionError(u'Expected last IR block to be ConstructResult, found: '
                               u'{} {}'.format(output_block, ir_blocks))
      ir_except_output = ir_blocks[:-1]
  
      folds, ir_except_output_and_folds = extract_folds_from_ir_blocks(ir_except_output)
  
      # Extract WHERE Filter
      global_operation_ir_blocks_tuple = _extract_global_operations(ir_except_output_and_folds)
      global_operation_blocks, pruned_ir_blocks = global_operation_ir_blocks_tuple
      if len(global_operation_blocks) > 1:
          raise AssertionError(u'Received IR blocks with multiple global operation blocks. Only one '
                               u'is allowed: {} {}'.format(global_operation_blocks, ir_blocks))
      if len(global_operation_blocks) == 1:
          if not isinstance(global_operation_blocks[0], Filter):
              raise AssertionError(u'Received non-Filter global operation block. {}'
                                   .format(global_operation_blocks[0]))
          where_block = global_operation_blocks[0]
      else:
          where_block = None
  
      match_steps = _split_ir_into_match_steps(pruned_ir_blocks)
  
      match_traversals = _split_match_steps_into_match_traversals(match_steps)
  
      return MatchQuery(
          match_traversals=match_traversals,
          folds=folds,
          output_block=output_block,
          where_block=where_block,
      )
docs: Convert the list of IR blocks into a MatchQuery object, for easier manipulation.