I don't understand the behaviour of containers in this example:
The part I don't unerstand is line 41. Why is lastContainer assigned to newContainer? In line 40, newContainer is added as a child of lastContainer; my intuition would be that the effect of line 40 is so that the rotations can be performed on lastContainer (or, rather, on containerTails, which seems to contain four nested container structures, one for each arm), and propagated to its children.
It makes no sense to me that the variable containing the parent container should be assigned to its own child; how does that not overwrite the nested structure of containers, effectively removing the parent container from the picture?