Adding recursive treeToList method.