def get_var(name, context, default=None):
    """ Get a variable from a dict context

    Parameters
    ----------
    name : str or list(str)
        variable name
    context : dict
        variable dict
    default:
        default value or function which creates the default
        value if failed to find var in context
    """
    if not isinstance(name, (list, tuple)):
        name = name,
    current_context = context
    for current_name in name:
        if current_name in current_context:
            current_context = current_context[current_name]
        elif callable(default):
            return default()
        else:
            return default
    return current_context
