This was re-introduced by 5d3e6e3d44
The crash happened b/c we have to manage list containers in each element
and minor adjustments cause the rest of the list to be lost. This
commit re-implements it using std::iterators and deque
Fixes#2623 | https://gitlab.com/kicad/code/kicad/issues/2623