def _rfind(stack, elem, default=None):
    """
    Like _find but starts from the back.
    """
    for i in reversed(range(len(stack))):
        if stack[i] == elem:
            return i
    else:
        return default
