'Reduce the token stack into an AST.'

def Reduce(self):

    if ((self.state != 'INITIAL') and (self.state != 'BINARY')):
        self.Error('Premature    end    of    expression')
    length = len(self.stack)
    while (length > 1):
        self._CombineParenthesis()
        self._CombineBinaryExpressions('and')
        self._CombineBinaryExpressions('or')
        self._CombineContext()
        if (len(self.stack) == length):
            break
        length = len(self.stack)
    if (length != 1):
        self.Error('Illegal    query    expression')
    return self.stack[0]
