in reply to file tree to hash

That's how I would do it. Why does it seem less than optimal? What do you mean by "best"?