<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _format_stack(self, stack, current=None):
 """Prettifies a scope stack for use in error messages. :param list(str) stack: List of scopes. :param str current: The current scope. If specified, will be appended onto the stack before formatting. :returns: str """

        if current is not None:
            stack = stack + [current]
        if len(stack) > 1:
            prefix = os.path.commonprefix(stack)
            if prefix.endswith('/'):
                prefix = prefix[:-1]
            stack = [scope[len(prefix):] for scope in stack]
        return ' => '.join(stack)