I need elegance and performance: how to decide by the best implementation for each DOM algorithm that I face. This simple DOMNodeList grouper illustrate many little dilemmas:use iterator_to_array or populate an array, when not all items need to be copied. use clone operator, cloneNode method or import method?use  parentNode::method() or documentElement::method? (see here)first removeChild or first replaceChild, no avoids side effects? ...My position, today, is only do an arbitrary choice and follow it in all implementations (like a Convention over configuration principle)... But, there are another considerations?  About performance, there are some article showing benchmarks?PS: this is a generic DOM question, any language (PHP, Javascript, Python, etc.) have the problem.
DOMDocument programming: a lot of little dilemmas, how to solve them?
dom