implemented tree and cotree with fold and unfold