implement decode string into tree