I have following code to construct a string from a given string recursively.
def queryGen(text, lastOP=\'\'): pattern = re.compile("\\((.+?)\\)\\s+(a