Encode using tree completed