def METHOD_NAME(instance, func_name, data):
    try:
        func = getattr(instance, func_name)
    except AttributeError as exc:
        raise InvalidPathError(f'Function {func_name} not found') from exc
    if isinstance(data, dict):
        return func(**data)
    if data is not None:
        return func(data)
    return func()