fix #11957 - partial revert of r8851 - do not replace Stack by ArrayDeque because of different iteration behaviour + add unit test
Stack
ArrayDeque