- if (lift && children != null && children.length > 0) {
- Tree<NodeType> last = children[children.length-1];
- this.children = new Tree[(children.length-1)+last.children.length];
- System.arraycopy(children, 0, this.children, 0, children.length-1);
- if (last.children.length > 0)
- System.arraycopy(last.children, 0, this.children, children.length-1, last.children.length);
- } else {
- this.children = ArrayUtil.clone(children, Tree.class);
+
+ int count = 0;
+ for(int i=0; i<children.length; i++)
+ count += lifts[i] ? children[i].size() : 1;
+
+ this.children = new Tree[count];
+ int j = 0;
+ for(int i=0; i<children.length; i++) {
+ if (!lifts[i])
+ this.children[j++] = children[i];
+ else
+ for(int k=0; k<children[i].size(); k++)
+ this.children[j++] = children[i].child(k);