construct tree and tree level output