def _first_step_to_match(match_step):
    """Transform the very first MATCH step into a MATCH query string."""
    parts = []

    if match_step.root_block is not None:
        if not isinstance(match_step.root_block, QueryRoot):
            raise AssertionError(u'Expected None or QueryRoot root block, received: '
                                 u'{} {}'.format(match_step.root_block, match_step))

        match_step.root_block.validate()

        start_class = get_only_element_from_collection(match_step.root_block.start_class)
        parts.append(u'class: %s' % (start_class,))

    # MATCH steps with a QueryRoot root block shouldn't have a 'coerce_type_block'.
    if match_step.coerce_type_block is not None:
        raise AssertionError(u'Invalid MATCH step: {}'.format(match_step))

    if match_step.where_block:
        match_step.where_block.validate()
        parts.append(u'where: (%s)' % (match_step.where_block.predicate.to_match(),))

    if match_step.as_block is None:
        raise AssertionError(u'Found a MATCH step without a corresponding Location. '
                             u'This should never happen: {}'.format(match_step))
    else:
        match_step.as_block.validate()
        parts.append(u'as: %s' % (_get_vertex_location_name(match_step.as_block.location),))

    return u'{{ %s }}' % (u', '.join(parts),)
Transform the very first MATCH step into a MATCH query string.