Nodes are equal when their IDs are equal. IDs in one tree are unique. On the schemas, IDs of nodes are visible.
Consider tree1
:
root
|
+-- CC
| |
| \-- ZZZ
| |
| \-- UU
|
\-- A
|
\-- HAH
And tree2
:
root
|
+-- A
|
+-- ADD
|
\-- HAH
I would like that merge(tree1, tree2)
will give this:
root
|
+-- CC
| |
| \-- ZZZ
| |
| \-- UU
|
\-- A
|
+-- HAH
|
\-- ADD
How to do it?
Node has typical methods like getParent()
, getChildren()
.
Order of the children doesn't matter. So, the result could be also:
root
|
+-- A
| |
| +-- ADD
| |
| \-- HAH
|
\-- CC
|
\-- ZZZ
|
\-- UU