works for certain strings like banana and peeper but not for long one when the tree has to be in more than 2-3 levels depth.