Extract some common code into AddChildrenToWorkSet function.
(It's a hard knock life)
This is a backport of [[https://github.com/bitcoin/bitcoin/pull/21148 | core#21148]] [4/14]
https://github.com/bitcoin/bitcoin/pull/21148/commits/ee135c8d5b39b0cb8b301a83e286285ab926dca7
Depends on D11483