def detect_loop(oCardSet):
    """Checks whether the given card set lead to a loop"""
    aSeen = [oCardSet]
    oParent = oCardSet.parent
    while oParent:
        if oParent in aSeen:
            return True
        aSeen.append(oParent)
        oParent = oParent.parent
    return False
