implement a tree structure with a copy function