code: def _sanity_check_mark_location_preceding_optional_traverse(ir_blocks):
      
      # Once all fold blocks are removed, each optional Traverse must have
      # a MarkLocation block immediately before it.
      _, new_ir_blocks = extract_folds_from_ir_blocks(ir_blocks)
      for first_block, second_block in pairwise(new_ir_blocks):
          # Traverse blocks with optional=True are immediately preceded by a MarkLocation block.
          if isinstance(second_block, Traverse) and second_block.optional:
              if not isinstance(first_block, MarkLocation):
                  raise AssertionError(u'Expected MarkLocation before Traverse with optional=True, '
                                       u'but none was found: {}'.format(ir_blocks))
docs: Assert that optional Traverse blocks are preceded by a MarkLocation.