function recPoly(node) {
      var tp = node.type; // node type

      if (tp === 'FunctionNode') {
        // No function call in polynomial expression
        throw new Error('There is an unsolved function call');
      } else if (tp === 'OperatorNode') {
        if (node.op === '^') {
          if (node.args[1].fn === 'unaryMinus') {
            node = node.args[0];
          }

          if (node.args[1].type !== 'ConstantNode' || !number.isInteger(parseFloat(node.args[1].value))) {
            throw new Error('There is a non-integer exponent');
          } else {
            recPoly(node.args[0]);
          }
        } else {
          if (oper.indexOf(node.op) === -1) {
            throw new Error('Operator ' + node.op + ' invalid in polynomial expression');
          }

          for (var i = 0; i < node.args.length; i++) {
            recPoly(node.args[i]);
          }
        } // type of operator

      } else if (tp === 'SymbolNode') {
        var name = node.name; // variable name

        var pos = variables.indexOf(name);

        if (pos === -1) {
          // new variable in expression
          variables.push(name);
        }
      } else if (tp === 'ParenthesisNode') {
        recPoly(node.content);
      } else if (tp !== 'ConstantNode') {
        throw new Error('type ' + tp + ' is not allowed in polynomial expression');
      }
    }
Function to simplify an expression using an optional scope and
 return it if the expression is a polynomial expression, i.e.
 an expression with one or more variables and the operators
 +, -, *, and ^, where the exponent can only be a positive integer.

Syntax:

    recPoly(node)


@param  {Node} node               The current sub tree expression in recursion

@return                           nothing, throw an exception if error