private void AddOperator(char value)
 {
     Operator newOperator = new Operator();
     switch (value)
     {
         case '+':
             newOperator = new AdditionOperator();
             break;
         case '-':
             newOperator = new SubtractionOperator();
             break;
         case '*':
             newOperator = new MultiplicationOperator();
             break;
         case '/':
             newOperator = new DivisionOperator();
             break;
         default:
             throw new UnexpectedSymbolException("There is must be an operator after a closing bracket.");
     }
     if (root == null)
     {
         root = newOperator;
         return;
     }
     bool isAdded = false;
     AddNode(newOperator, root, ref isAdded);
 }
 private void AddNode(INode node, Operator pointer, ref bool isAdded)
 {
     if (!isAdded)
     {
         if (pointer.LeftNode == null)
         {
             pointer.LeftNode = node;
             isAdded = true;
             return;
         }
         if (pointer.LeftNode is Operator)
         {
             Operator op = pointer.LeftNode as Operator;
             AddNode(node, op, ref isAdded);
         }
     }
     if (!isAdded)
     {
         if (pointer.RightNode == null)
         {
             pointer.RightNode = node;
             isAdded = true;
             return;
         }
         if (pointer.RightNode is Operator)
         {
             Operator op = pointer.RightNode as Operator;
             AddNode(node, op, ref isAdded);
         }
     }
 }