Deduplicate Stackframes
The trimming of stacktraces is currently relatively dumb, it cuts down the total amount of stack frames to 250 then afterwards tries to trim non app frames from the remaining frames until there are 50 frames left.
We can make the trimming smarter by trying to prioritize removing duplicate frames. We probably should keep a few of the duplicates not remove all or communicate in the event metadata that there were duplicate frames removed, to show the user that there were indeed duplicates.
This would help a lot for recursions.
Note duplicate detections does need to be aware of cycles, for example a recursion stack trace could look something like: x -> a -> a -> a -> a -> a but also like x -> a -> b -> c -> a -> b -> c -> a -> b -> c.
See also: #3905
Assuming we would transform x -> a -> a -> a -> a -> a into something like x -> (a)* and x -> a -> b -> c -> a -> b -> c -> a -> b -> c into something like x -> (a -> b -> c)* would we want to transform x -> a -> b -> b -> a -> b -> b into x -> a -> (b)* -> a -> (b)* or rather x -> (a -> b -> b)*?