created tree structure and functions to add nodes and clean up nodes