public static HashSet<T> FindAll<T>(this IExpr expr, Func<T, bool> f) where T : class, IExpr { var all = new HashSet<T>(); expr.Traverse(e => { if (e is T && f((T)e)) all.Add((T)e); }, mode: TraverseMode.STOP_BEFORE_VISITED); return all; }