dom/node_set: cleanup code and logic