def findAncestor(acc, pred):
        """
        Searches for an ancestor satisfying the given predicate. Note that the
        AT-SPI hierarchy is not always doubly linked. Node A may consider node B its
        child, but B is not guaranteed to have node A as its parent (i.e. its parent
        may be set to None). This means some searches may never make it all the way
        up the hierarchy to the desktop level.

        @param acc: Starting accessible object
        @type acc: Accessibility.Accessible
        @param pred: Search predicate returning True if accessible matches the 
                search criteria or False otherwise
        @type pred: callable
        @return: Node matching the criteria or None if not found
        @rtype: Accessibility.Accessible
        """
        if acc is None:
                # guard against bad start condition
                return None
        while 1:
                if acc.parent is None:
                        # stop if there is no parent and we haven't returned yet
                        return None
                try:
                        if pred(acc.parent): return acc.parent
                except Exception:
                        pass
                # move to the parent
                acc = acc.parent