@NotNull
  static <T> List<T> pull(Queue<T> queue) {
    List<T> result = new ArrayList<T>();
    T last = queue.poll();
    if(last == null) return result;
    result.add(last);
    while((last = queue.poll())!=null) {
      result.add(last);
    }
    return result;
  }
@NotNull
  static <T> List<T> pull(Queue<T> queue)