def flatten_list(x):
    """ Flatten a hierarchy of lists """
    result = []
    for y in x:
        if isinstance(y, list):
            result.extend(flatten_list(y))
        else:
            result.append(y)
    return result