tweaked getParentElementByName