/** Recursive into children: clones the whole tree from this node downward. */ public TemplateThing clone(final Project pr, final boolean copy_id) { final long nid = copy_id ? this.id : pr.getLoader().getNextId(); final TemplateThing copy = new TemplateThing(this.type, pr, nid); copy.project = pr; copy.addToDatabase(); // clone children if (null == al_children) return copy; for (final TemplateThing child : al_children) { copy.addChild(child.clone(pr, copy_id)); } return copy; }