protected static <T> void replaceOrAppend(List<T> list, T from, T to) {
    int index = list.indexOf(from);
    if (index == -1) index = list.size();
    list.remove(from);
    list.add(index, to);
  }
protected static <T> void replaceOrAppend(List<T> list, T from, T to)