def flatten(nested_list):
    """
    Flatten an arbitrarily nested list.
    Nesting may occur when anchors are used inside a YAML list.
    """
    flattened = []
    for l in nested_list:
        if isinstance(l, list):
            flattened.extend(flatten(l))
        else:
            flattened.append(l)
    return flattened