Added the decode and encode function to the Tree