Collapse similar stack trace elements when adding them to the StackGraph