Easily get to the n-th parent element or to the first parent element which matches a selector:
var element = document.getElementsByClassName("example")
element.P(2) // ➜ element.parentElement.parentElement
element.P() // ➜ element.parentElement
element.P("body") // ➜ document.body, or null if the element doesn't exist in the DOM
element.P(document.head) // ➜ document.head or null
This script is compatible with all major browsers, including IE9+.
public domain / cc0