Modern browsers have the Element.closest() method.
Example:
document.querySelector('.navPanel img').closest('td')
Reference:
https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
Here you can check which browsers have built-in support:
https://caniuse.com/#feat=element-closest
When there is no support in the browser the following polyfill could be used:
https://github.com/jonathantneal/closest