First treeFold implementation
Another version of treeFold, I still don't like it