diff --git a/python/egglog/declarations.py b/python/egglog/declarations.py index e1f4bbfd..7e3e80cb 100644 --- a/python/egglog/declarations.py +++ b/python/egglog/declarations.py @@ -1000,6 +1000,16 @@ def from_egg( def to_egg(self, decls: Declarations) -> bindings._Expr: return self.expr.to_egg(decls) + def descendants(self) -> list[TypedExprDecl]: + """ + Returns a list of all the descendants of this expression. + """ + l = [self] + if isinstance(self.expr, CallDecl): + for a in self.expr.args: + l.extend(a.descendants()) + return l + @dataclass class ClassDecl: