Copying an element with its children.

My project needs to implement the following functionality:
There are guides that users create. On their basis, projects are created by other users. On the basis of each guide can be created an unlimited number of projects. But when creating a project, the selected guide must be copied, and the project itself will already contain a copy of the selected guide.
It is necessary so that when you work on a project, any changes in its guide will not affect the main guide.
The problem is that the guide contains child elements that must also be copied. Structure of the Hyde: Phases (data type - list of phases); Phases contain Steps (data type - list of steps); Steps contain Tasks (data type - list of tasks).
Accordingly, when copying the guide, it is necessary that all child elements and their children are also copied. But at the same time the connection between them is not broken. That is, all the Tasks should correspond to their Steps. All Steps correspond to their Phases. And all Phases belonged to their Guide.
And when you change, for example, any task within the project, these changes occurred only to a copy of the guide, but did not affect the main guide.

1 Like