Flattens a nested array.