Figma layers tree traversal + estimating size

You need to pause this async task every now and then for a couple of milliseconds. The simplest way is to do it on every Xth node, e.g. every 100 or so. Just use a custom delay function, you can easily find async sleep or pause functions on the web. They use timeout and simply turn it into an async function. Hope this helps!