Compare the common keys between security group rules against eachother

def _rule_compare(rule1, rule2):
    '''
    Compare the common keys between security group rules against eachother
    '''

    commonkeys = set(rule1.keys()).intersection(rule2.keys())
    for key in commonkeys:
        if rule1[key] != rule2[key]:
            return False
    return True