SI-7221 Rewrites pollForWork tail-recursively

Fixes #1001407