class Node {
    Node previous;
    Node next;
    CompletableFuture<Void> future;
  }

  /**
   * Adds a new CompletableFuture to the list and returns it. The returned future will be removed from the list when
   * it's completed.
   */
  public synchronized CompletableFuture<Void> add() {
    Node node = new Node();
    node.future = new CompletableFuture<>();
    node.future.whenComplete((result, error) -> remove(node));

    if (head == null)
      head = tail = node;
    else {
      tail.next = node;
      node.previous = tail;
      tail = node;
    }
    return node.future;
  }

  /**
   * Returns and removes the first future in the list, else returns {@code null} if the list is empty.
   */
  public synchronized CompletableFuture<Void> pollFirst() {<FILL_FUNCTION_BODY>

    Node previousHead = head;
    if (head != null) {
      head = head.next;
      if (head != null)
        head.previous = null;
    }
    return previousHead == null ? null : previousHead.future;
  
<no_super_class>