implement tree structure