private ASTNode pushToStack(Stack<OperatorNode> operatorStack,Stack<ASTNode> valueStack,ASTNode newNode,ASTNode lastAddedNode) 
    {
        if ( ! ( newNode instanceof OperatorNode ) ) {
            valueStack.push( newNode );
            // System.out.println("VALUE: PUSH "+newNode);
            return lastAddedNode;
        }
        
        final OperatorNode x = (OperatorNode) newNode;
        
        /*
    For all the input tokens [S1]:

        - Read the next token [S2];
        - If token is an operator (x) [S3]:
            - While there is an operator (y) at the top of the operators stack and either (x) is
              left-associative and its precedence is less or equal to that of (y), or (x) is right-associative
              and its precedence is less than (y) [S4]:

         * Pop (y) from the stack [S5];
         * Add (y) output buffer [S6];
            - Push (x) on the stack [S7];

          Else If token is left parenthesis, then push it on the stack [S8];

          Else If token is a right parenthesis [S9]:
            Until the top token (from the stack) is left parenthesis, pop from the stack to the output buffer [S10];
            Also pop the left parenthesis but don’t include it in the output buffer [S11];

          Else add token to output buffer [S12].

        - While there are still operator tokens in the stack, pop them to output [S13]
         */
        // System.out.println("CURRENT OPERATOR: "+x);  
        if ( ! operatorStack.isEmpty()  ) {

            final OperatorNode y = operatorStack.peek();
            if ( ( isLeftAssociative(x) && getPrecedence( x ) <= getPrecedence( y ) ) ||
                   ( isRightAssociative(x) && getPrecedence( x ) < getPrecedence( y ) ) )
            {
            	if ( isLeftAssociative( x ) ) {
            		// System.out.println("Left-associative operator "+x+" has <= precedence than "+y);            		
            	} else {
            		// System.out.println("Right-associative operator "+x+" has < precedence than "+y);
            	}
                ASTNode result = popOperatorFromStack(operatorStack, valueStack,lastAddedNode,false);
                // System.out.println("OPERATOR: PUSH "+x);  
                operatorStack.push( x );
                return result;
            } 
            // System.out.println("OPERATOR: PUSH "+x);            
            operatorStack.push( x );                  
        } else {
            // System.out.println("OPERATOR: PUSH "+x);  
            operatorStack.push( x );            
        }
        return lastAddedNode;
    }