@staticmethod
def _getAncestor(adaptor, tokenNames, t, goal):
    """Helper for static inContext."""
    while t is not None:
        name = tokenNames[adaptor.getType(t)]
        if name == goal:
            return t
        t = adaptor.getParent(t)
    return None
