xxxxxxxxxx
function getParentNode(element, level = 1) { // 1 - default value (if no 'level' parameter is passed to the function)
while (level-- > 0) {
element = element.parentNode;
if (!element) return null; // to avoid a possible "TypeError: Cannot read property 'parentNode' of null" if the requested level is higher than document
}
return element;
}