Make Data.Tree.flatten a good producer

Write it using `build` to fuse with `foldr` et al.