'Converts a tree to string with translations.
Function names are translated by translate_func.
Other strings are translated by translate_str.'

def tree2str_translate(self, tree):

    if isinstance(tree, str):
        return self.translate_str(tree)
    elif (isinstance(tree, tuple) and (len(tree) == 2)):
        return self.translate_func(tree[0][:(-1)], tree[1])
    else:
        return ''.join([self.tree2str_translate(t) for t in tree])
