[WTO] Make `expand` tail recursive
[WTO] Make `expand` tail recursive

Summary:
In some corner cases where there are a lot of sequential statements, it raised stack overflow.  To
avoid the issue, this diff changes the function as tail recursive by passing a callback function.

Reviewed By: ngorogiannis

Differential Revision: D26668338

fbshipit-source-id: 822d9a5f8

jvillard/infer,jvillard/infer,jvillard/infer,facebook/infer,jvillard/infer,facebook/infer,facebook/infer,facebook/infer,facebook/infer,facebook/infer,jvillard/infer,facebook/infer,jvillard/infer,jvillard/infer