def METHOD_NAME(addr, flags=None):
    """Factory method to create a BaseIpAddress object"""
    if isinstance(addr, BaseIpAddress):
        return addr
    elif isinstance(addr, str):
        try:
            return Ip4Address(addr, flags)
        except:
            return Ip6Address(addr, flags)
    else:
        raise LnstError("Value must be a BaseIpAddress or string object."
                        " Not {}".format(type(addr)))