export function getParentDeepAttribute( element: Element, attributeName: string, ): string | null { //todo maybe do implementation via getParentDeep if (element.hasAttribute(attributeName)) { return element.getAttribute(attributeName)!; } else if (element.parentElement) { return getParentDeepAttribute(element.parentElement, attributeName); } else { return null; } } export function getParentDeep( element: Element, callback: (element: Element) => boolean, getSelf = false, ): Element | null { if (getSelf && callback(element)) { return element; } else if (element.parentElement) { return getParentDeep(element.parentElement, callback, true); } else { return null; } } export function getChildrenDeepAttribute( element: Element, attributeName: string, ): string | null { //todo maybe do implementation via universal //todo search whole tree if (element.hasAttribute(attributeName)) { return element.getAttribute(attributeName)!; } else if (element.children[0]) { return getParentDeepAttribute(element.children[0], attributeName); } else { return null; } }