Determine a retcode for a given return

def _get_retcode(self, ret):
        '''
        Determine a retcode for a given return
        '''
        retcode = 0
        # if there is a dict with retcode, use that
        if isinstance(ret, dict) and ret.get('retcode', 0) != 0:
            if isinstance(ret.get('retcode', 0), dict):
                return max(six.itervalues(ret.get('retcode', {0: 0})))
            return ret['retcode']
        # if its a boolean, False means 1
        elif isinstance(ret, bool) and not ret:
            return 1
        return retcode