static bool addIfNotEqualToLast<T>(List<T> list, T item) { if (list.isEmpty || list.last == item) { list.add(item); return true; } return false; }