def _getvaluefrombuffer(buf, loc):
    """Returns a requested value from buffer.
    Function is called recursively.

    Parameters
    ----------
    buf : dict
        Buffer object
    loc : list
        List of strings with the requested location within buf

    Returns
    -------
    ret : object
        Reqested value in buf at position loc"""
    if len(loc) > 1:
        return _getvaluefrombuffer(buf.__dict__[loc[0]], loc[1:])
    if not hasattr(buf, loc[0]):
        raise RuntimeError("Requested <field> does not exist.")
    return buf.__dict__[loc[0]]