Implemented depth-first string to tree