ancestor

returns ancestor elements.

Source


def ancestor(self):
    if self.has_parent():
        ret = pyNodeList()
        par = self._parent
        ret.append(par)
        while par.has_parent():
            par = par._parent
            ret.append(par)
        if len(ret) == 1: return ret[0]
        else: return ret
    return None