convert string to tree output (not thoroughly tested)