Tidied up foldTree