def get_el_path(el):
    """
    Returns itself and its ancestors.

    >>> import lxml.html
    >>> doc = lxml.html.fromstring('<html><body><h1>Hi <em>there</em></h1><p>Bye.</p></body></html>')
    >>> path = get_el_path(doc.xpath('//em')[0])
    >>> [p.tag for p in path]
    ['em', 'h1', 'body', 'html']
    """
    parents = []
    cur = el
    while cur is not None:
        parents.append(cur)
        cur = cur.getparent()
    return parents