create a tree structure