/// <summary>
        /// Creates a new instance of <see cref="SwitchStatement" />, copying all the cases of the specified statement, replacing the last case with one that adds the specified statements.
        /// </summary>
        /// <param name="statement">The switch statement to copy all cases from.</param>
        /// <param name="statements">A sequence of statements to append to the last case.</param>
        /// <returns>a new instance of <see cref="SwitchStatement" /></returns>
        /// <remarks>
        /// The specified instance of <see cref="SwitchStatement" /> must already have at least one case for this method to succeed.
        /// </remarks>
        public static SwitchStatement Do(this SwitchStatement statement, IEnumerable<Statement> statements)
        {
            if (statement == null)
            {
                throw new ArgumentNullException("statement");
            }

            if (!statement.Cases.Any())
            {
                throw new InvalidOperationException("Can't invoke Do() on a switch statement without cases.");
            }

            SwitchStatement @switch = new SwitchStatement(statement.Expression, statement.Cases);

            if (statements != null)
            {
                int lastIndex = @switch.Cases.Count - 1;
                CaseStatement lastCase = @switch.Cases[lastIndex];
                CaseStatement newLast = new CaseStatement(lastCase.Value, lastCase.Statements.Union(statements));
                @switch.Cases[lastIndex] = newLast;
            }

            return @switch;
        }