def isAncestorOf(ancestor, child):
    """Return True if `ancestor` is an ancestor of `child`, QObject-tree-wise."""
    while child is not None:
        if child is ancestor:
            return True
        child = child.parent()
    return False
