# [Charcoal], <s>122</s> 120 bytes

 ≔&θ⁰η≔⟦η⟧ζFζFιF⁼κ⁺⟦⟧κ«UMκ⊖μ⊞ζκ»⊞υθ⊞υηFυFιF⁼κ⁺⟦⟧κ⊞υκF⮌υ«≔⟦⟧ζWι⊞ζ⊟ιF⮌ζ¿⁺⟦⟧κFκ⊞ιλ⊞ικ»≔⮌θθ≔⁰ζF⁻η⊖⌊η«F⁻ζι]→F⁻ιζ[I⊟θ≔ιζ»Fζ]UB,

[Try it online!][TIO-l41ytfik] Link is to verbose version of code. Explanation: Not an easy problem to solve without access to recursion.

 ≔&θ⁰η

Make a deep clone of the input and set all of the integers in that clone to zero. (`BitwiseAnd` fully vectorises, unlike, say, `Times`.)

 ≔⟦η⟧ζFζFιF⁼κ⁺⟦⟧κ«UMκ⊖μ⊞ζκ»

Perform a breadth-first search over the clone and decrement each sublist. (Again, it is fortunate that `Decremented` fully vectorises, although I still have to `MapCommand` it because I need to modify each sublist in-place.) The resulting list ends up with values appropriate to their depth.

 ⊞υθ⊞υηFυFιF⁼κ⁺⟦⟧κ⊞υκF⮌υ«≔⟦⟧ζWι⊞ζ⊟ιF⮌ζ¿⁺⟦⟧κFκ⊞ιλ⊞ικ»

Flatten both the input and the depth clone in-place.

 ≔⮌θθ≔⁰ζF⁻η⊖⌊η«F⁻ζι]→F⁻ιζ[I⊟θ≔ιζ»Fζ]UB,

Adjust the depth list so that the minimum depth is 1, and use that to build the desired output list from the depth list and the flattened input list. (See my answer to https://codegolf.stackexchange.com/questions/241633/ for more detail.)

[Charcoal]: https://github.com/somebody1234/Charcoal
[TIO-l41ytfik]: https://tio.run/##jVFNj4IwED3Lr2g4tUlNXL2tJ3X3aGLcY8OhwWonFBBKNWHjb2cHaAne9tTOzJv30aZa1mkpTdftrIVbQffQPMGqXXGhFScrxolm28gPhU44abG@ljWhLSPDCf78rpw0lmacnIyzVCA2Y4yR32hxlPdDmecSWXH8pdJa5apo1IXmDOkWJ2c1bXv8NnpFQ@U4qbAKdx1U3T9Vw2IWFs/qoWqrkGCwFCL5RIunBqMG2mDmVN6x7Gdv@y3uw5XQudxoJfO7wIlhW6KMVVNjTOZFA1XFxpC@vZo97hEKpNfvj4VNyF1ONfPvOoOiYehj11A0NE7i3vexfCj6eYabbqYYIxp6qQktBvRYHKRtaB@9YkN27w1Gb6/p6@dCP6rZyzS71aXDH4459rpOiA0Xay4@Er5O@CZJuuXD/AE "Charcoal – Try It Online"