Support recursive structs

Nested structs, for example `(b(oss))`, made the program crash because a collection may not be modified while it is still in the process of being iterated. This can be fixed by iterating a copy instead.