Construct a MatchStep from a tuple of its constituent blocks.

def _per_location_tuple_to_step(ir_tuple):
    """Construct a MatchStep from a tuple of its constituent blocks."""
    root_block = ir_tuple[0]
    if not isinstance(root_block, root_block_types):
        raise AssertionError(u'Unexpected root block type for MatchStep: '
                             u'{} {}'.format(root_block, ir_tuple))

    coerce_type_block = None
    where_block = None
    as_block = None
    for block in ir_tuple[1:]:
        if isinstance(block, CoerceType):
            if coerce_type_block is not None:
                raise AssertionError(u'Unexpectedly found two blocks eligible for "class" clause: '
                                     u'{} {} {}'.format(block, coerce_type_block, ir_tuple))
            coerce_type_block = block
        elif isinstance(block, MarkLocation):
            if as_block is not None:
                raise AssertionError(u'Unexpectedly found two blocks eligible for "as" clause: '
                                     u'{} {} {}'.format(block, as_block, ir_tuple))
            as_block = block
        elif isinstance(block, Filter):
            if where_block is not None:
                raise AssertionError(u'Unexpectedly found two blocks eligible for "where" clause: '
                                     u'{} {} {}'.format(block, as_block, ir_tuple))

            # Filter always comes before MarkLocation in a given MatchStep.
            if as_block is not None:
                raise AssertionError(u'Unexpectedly found MarkLocation before Filter in '
                                     u'MatchStep: {} {} {}'.format(block, where_block, ir_tuple))

            where_block = block
        else:
            raise AssertionError(u'Unexpected block encountered: {} {}'.format(block, ir_tuple))

    step = MatchStep(root_block=root_block,
                     coerce_type_block=coerce_type_block,
                     where_block=where_block,
                     as_block=as_block)

    # MatchSteps with Backtrack as the root block should only contain MarkLocation,
    # and not do filtering or type coercion.
    if isinstance(root_block, Backtrack):
        if where_block is not None or coerce_type_block is not None:
            raise AssertionError(u'Unexpected blocks in Backtrack-based MatchStep: {}'.format(step))

    return step