Here's a better implementation by @bb-mausbrand ```py def logics_dump(l): def _dump(a, level=0): if a.emit: res = f"""{' '*level}{a.emit}""" if a.match and a.match != a.emit: res += f""" {a.match}""" yield res level += 1 for child in a.children: if child: yield from _dump(child, level=level) return list(_dump(l.ast)) ```