def get_val(data, *args):
    """Accesses elements in a hierarchy.

    It will check on each level whether it exists. If not, `None`
    will be returned. If it does exist it traveres down."""

    pos = data
    for key in args:
        if not isinstance(pos, dict):
            return None
        if key not in pos:
            return None
        pos = pos[key]
    return pos