docs: def ancestor(self, n):
          """
          Return the n-th ancestor.
          Note that ``elem.ancestor(1) == elem.parent``
  
          :rtype: :class:`Element` | ``None``
          """
          if not isinstance(n, int) or n < 1:
              raise TypeError('Ancestor needs to be positive, received', n)
  
          if n == 1 or self.parent is None:
              return self.parent
          else:
              return self.parent.ancestor(n-1)