def get_var(df, recorded_var, mean=True):
    """
    Get variable from dataframe one level deep and optionally the mean.

    :param df: Recorded data over time
    :type df: pd.DataFrame
    :param recorded_var: Variable to retrieve from df
    :type recorded_var: str
    :param mean: Include the mean in the return tuple
    :type mean: bool
    :return: Dataframe of variable and Series of the mean for the variable for each time step
    :rtype: (pd.DataFrame, pd.Series or None)
    """
    all_var_columns = df.xs(recorded_var, level=1, axis=1)
    if mean:
        # mean over the columns
        mean_val = all_var_columns.mean(axis=1)
    else:
        mean_val = None
    return all_var_columns, mean_val