easy - accepted / - tried
Given a DOM tree, flatten it into an one dimensional array, in the order of layer by layer, like below.
Bugfree ordinary solution is better than buggy fancy ones.