Split a list of MatchSteps into multiple lists, each denoting a single MATCH traversal.

def _split_match_steps_into_match_traversals(match_steps):
    """Split a list of MatchSteps into multiple lists, each denoting a single MATCH traversal."""
    output = []
    current_list = None
    for step in match_steps:
        if isinstance(step.root_block, QueryRoot):
            if current_list is not None:
                output.append(current_list)
            current_list = [step]
        else:
            current_list.append(step)

    if current_list is None:
        raise AssertionError(u'current_list was unexpectedly None: {}'.format(match_steps))
    output.append(current_list)

    return output