'Gets bans merged once, a helper for lambda(s), prevents stop of executing action by any exception inside.
This function never returns None for ainfo lambdas - always a ticket (merged or single one)
and prevents any errors through merging (to guarantee ban actions will be executed).
[TODO] move merging to observer - here we could wait for merge and read already merged info from a database
Parameters
overalljails : bool
switch to get a merged bans :
False - (default) bans merged for current jail only
True - bans merged for all jails of current ip address
Returns
BanTicket
merged or self ticket only'

def _mi4ip(self, overalljails=False):

    if (not hasattr(self, '__mi4ip')):
        self.__mi4ip = {}
    mi = self.__mi4ip
    idx = ('all' if overalljails else 'jail')
    if (idx in mi):
        return (mi[idx] if (mi[idx] is not None) else self.__ticket)
    try:
        jail = self.__jail
        ip = self['ip']
        mi[idx] = None
        if (not jail.database):
            return self.__ticket
        if overalljails:
            mi[idx] = jail.database.getBansMerged(ip=ip)
        else:
            mi[idx] = jail.database.getBansMerged(ip=ip, jail=jail)
    except Exception as e:
        logSys.error("Failed    to    get    %s    bans    merged,    jail    '%s':    %s", idx, jail.name, e, exc_info=(logSys.getEffectiveLevel() <= logging.DEBUG))
    return (mi[idx] if (mi[idx] is not None) else self.__ticket)
