void addTo<T>(List<T> target, List parts) { for (final part in parts) { if (part is T) { target.add(part); } else if (part is List) { addTo<T>(target, part); } } }