/// <summary>
        /// Merge current expression with previous expression and the new operand just got before current expression
        /// </summary>
        /// <param name="prevExpression"></param>
        /// <param name="curExpression"></param>
        /// <param name="newOperand"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public static bool MergeExpressions(ArithmeticExpression <ICalculator> prevExpression, ref ArithmeticExpression <ICalculator> curExpression, ref ArithmeticOperand <ICalculator> newOperand, ref string errMsg)
        {
            if (prevExpression == null || curExpression == null)
            {
                errMsg += "prevExpression is null or curExpression is null in MergeExpressions.";
                return(false);
            }

            if (prevExpression.Priority() < curExpression.Priority())
            {
                curExpression.AddOperand(newOperand);
                prevExpression.AddOperand(curExpression);
            }
            else if (prevExpression.Priority() > curExpression.Priority())
            {
                prevExpression.AddOperand(newOperand);
                if (prevExpression.ParentExpression != null && prevExpression.ParentExpression.Priority() == curExpression.Priority())
                {
                    prevExpression.ParentExpression.Operators.AddRange(curExpression.Operators);
                    prevExpression.ParentExpression.AddOperands(curExpression.Operands);
                    curExpression = prevExpression.ParentExpression;
                }
                else
                {
                    curExpression.AddOperand(prevExpression);
                }
            }
            else
            {
                prevExpression.AddOperand(newOperand);
                prevExpression.Operators.AddRange(curExpression.Operators);
                prevExpression.AddOperands(curExpression.Operands);
                curExpression = prevExpression;
            }
            newOperand = null;

            return(true);
        }