Code cleanup: Added list helpers to DOMUtils and used them in WTS

* Removes repetitive code and makes conditions easier to read.
* No change in parser test results.

Change-Id: I01c33efd99f7ba2d6097d2d912a33f9dd34d3e66