def maybe_call(maybe_fn, kwargs: dict, prefix: str = None) -> 'Any':
    """
    If maybe_fn is a function, get its arguments from kwargs and call it, also
    searching for prefixed kwargs if prefix is specified. Otherwise, return
    maybe_fn.

    Used to allow both functions and iterables to be passed into plotting
    functions.

    >>> def square(x): return x * x
    >>> maybe_call(square, {'x': 10})
    100

    >>> data = [1, 2, 3]
    >>> maybe_call(data, {'x': 10})
    [1, 2, 3]
    """
    if not callable(maybe_fn):
        return maybe_fn

    args = get_fn_args(maybe_fn, kwargs, prefix=prefix)
    return maybe_fn(**args)