   Dynamic Systems
  Hy everybody,in my system i've an usual tree-structure of items, each one having a parent node and a list of children nodes.I define a "primitive" some function that a node can execute. The execution of a primitive manipulates the entine tree-structure changing parent-children relations. Primitives that can change objects internal data exists too.Examples of primitives are:- object A moves into object B- object X exits from its parent Y- state of object Z changes from S0 to S1- and so on...Each time i do execute a primitive a new system is created from the old one. Actually i'm storing systems resulting in primitives execution in a queue:MySystem currentSystem = systemsQueue.Peek();MySystem nextSystem = deepCopy(currentSystem);Primitive p = nextSystem.getNextPrimitive();p.execute();systemsQueue.Push(nextSystem);Before executing a primitive i do copy the entire system and then execute the primitive from it. I feel like i'm wasting a lot of memory holding multiple copies of duplicated data and of the list of all primitives.I could store just one primitive list in a super type (something storing a collection of MySystem objects and a list of primitives). The problem with this alternative approach is that i would have to reference objects in some special way (like using id numbers or similar) adding, in my opinion, too much complexity.Please give any suggestion...Recap:I want to store multiple copies of the full tree structure using the least possible memory (take into account the fact that a singleton list of primitives exists where each one uses memory pointers to reference objects and not names/ids).Tnx in advance   