DOM traversal utility