//---------------------------------------------------------------------------------
        /// <summary>
        /// Go to another level of a stack
        /// </summary>
        //---------------------------------------------------------------------------------
        public void GoToStackLevel(string stackName, int stackLevel)
        {
            if (_git.HasUncommittedChanges)
            {
                throw new ShortStackException("There are uncommitted changes.");
            }

            var selectedStack = CurrentStack;

            if (stackName != null)
            {
                selectedStack = _stacksCache.Values
                                .Where(s => s.StackName.ToLowerInvariant() == stackName.ToLowerInvariant())
                                .FirstOrDefault();
            }

            if (selectedStack == null)
            {
                if (stackName == null)
                {
                    throw new ShortStackException("Not currently on a stack.");
                }
                else
                {
                    throw new ShortStackException($"Could not find stack named '{stackName}'");
                }
            }

            if (stackLevel < 0)
            {
                throw new ShortStackException($"Invalid stack level {stackLevel}");
            }

            if (stackLevel >= selectedStack.Levels.Count)
            {
                stackLevel = selectedStack.Levels.Count - 1;
            }

            if (CurrentStack != null)
            {
                CurrentStack.SetCurrentLevel(null);
            }

            var targetStackLevel = selectedStack.Levels[stackLevel];

            _git.Checkout(targetStackLevel.LocalBranch);
            selectedStack.SetCurrentLevel(targetStackLevel);
        }