<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def pretty_print_gremlin(gremlin):
 """Return a human-readable representation of a gremlin command string."""

    gremlin = remove_custom_formatting(gremlin)
    too_many_parts = re.split(r'([)}]|scatter)[ ]?\.', gremlin)

    # Put the ) and } back on.
    parts = [
        too_many_parts[i] + too_many_parts[i + 1]
        for i in six.moves.xrange(0, len(too_many_parts) - 1, 2)
    ]
    parts.append(too_many_parts[-1])

    # Put the . back on.
    for i in six.moves.xrange(1, len(parts)):
        parts[i] = '.' + parts[i]

    indentation = 0
    indentation_increment = 4
    output = []
    for current_part in parts:
        if any([current_part.startswith('.out'),
                current_part.startswith('.in'),
                current_part.startswith('.ifThenElse')]):
            indentation += indentation_increment
        elif current_part.startswith('.back') or current_part.startswith('.optional'):
            indentation -= indentation_increment
            if indentation < 0:
                raise AssertionError(u'Indentation became negative: {}'.format(indentation))

        output.append((' ' * indentation) + current_part)

    return '\n'.join(output).strip()