Minor improvements to etree helper functions.