def get_last_position(fit, warmup=False):
    """Parse last position from fit object

    Parameters
    ----------
    fit : StanFit4Model
    warmup : bool
        If True, returns the last warmup position, when warmup has been done.
        Otherwise function returns the first sample position.

    Returns
    -------
    list
        list contains a dictionary of last draw from each chain.
    """
    fit._verify_has_samples()
    positions = []
    extracted = fit.extract(permuted=False, pars=fit.model_pars, inc_warmup=warmup)

    draw_location = -1
    if warmup:
        draw_location += max(1, fit.sim["warmup"])

    chains = fit.sim["chains"]
    for i in range(chains):
        extract_pos = {key : values[draw_location, i] for key, values in extracted.items()}
        positions.append(extract_pos)
    return positions