Optimizing E-Graphs pattern matcher: a complicated problem

With Metatheory.jl, I have a big performance problem when pattern matching against egraphs, a fairly complex algorithm and data structure

If anyone is skilled enough or willing to attack this problem. Please let me know. It’s certainly a valid contribution for the upcoming paper about Metatheory.jl, and I’m eager to invite anyone who helps me solve this issue as a coauthor. I may also think about placing a bounty for this performance problem.
I’m eager to provide any kind explanation. Please ping me.