static <A> List<A> append(List<? extends A> xs, A x) {
    ArrayList<A> result = new ArrayList<>();
    if (xs != null) {
      result.addAll(xs);
    }
    result.add(x);
    return result;
  }
static <A> List<A> append(List<? extends A> xs, A x)