Traverse DOM elements recursively.