Check deep equality between sorts if needed

Due to UnsafeExpr users, we can have statically and
dynamically allocated sorts. Thus, it's not sufficient
to simply check for pointer equality.