def parseTree(self):
        if self.ttype != BEGIN:
            return None

        self.ttype = self.tokenizer.nextToken()
        root = self.parseNode()
        if root is None:
            return None

        while self.ttype in (BEGIN, ID, PERCENT, DOT):
            if self.ttype == BEGIN:
                subtree = self.parseTree()
                self.adaptor.addChild(root, subtree)

            else:
                child = self.parseNode()
                if child is None:
                    return None

                self.adaptor.addChild(root, child)

        if self.ttype != END:
            return None

        self.ttype = self.tokenizer.nextToken()
        return root
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/antlr3/antlr3/treewizard.py/TreePatternParser.parseTree/original