// Path: src/main/java/com/twitter/http2/HttpCodecUtil.java
// static final int HTTP_DEFAULT_WEIGHT = 16;
// 
// Path: src/main/java/com/twitter/http2/HttpCodecUtil.java
// static final int HTTP_CONNECTION_STREAM_ID = 0;


import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
import io.netty.channel.ChannelPromise;
import io.netty.util.internal.EmptyArrays;
import static com.twitter.http2.HttpCodecUtil.HTTP_DEFAULT_WEIGHT;
import static com.twitter.http2.HttpCodecUtil.HTTP_CONNECTION_STREAM_ID;
    PendingWrite getPendingWrite(int streamId) {
        if (streamId == HTTP_CONNECTION_STREAM_ID) {
            Node connection = streams.get(HTTP_CONNECTION_STREAM_ID);
            return getPendingWrite(connection);
        }

        Node stream = streams.get(streamId);
        StreamState state = stream == null ? null : stream.state;
        return state != null ? state.getPendingWrite() : null;
    }

    PendingWrite getPendingWrite(Node node) {
        PendingWrite e = null;
        if (node.state != null && node.state.getSendWindowSize() > 0) {
            e = node.state.getPendingWrite();
        }
        if (e == null) {
            for (Node child : node.children) {
                e = getPendingWrite(child);
                if (e != null) {
                    break;
                }
            }
        }
        return e;
    }

    PendingWrite removePendingWrite(int streamId) {
        Node stream = streams.get(streamId);
        StreamState state = stream == null ? null : stream.state;
// Path: src/main/java/com/twitter/http2/HttpCodecUtil.java
// static final int HTTP_DEFAULT_WEIGHT = 16;
// 
// Path: src/main/java/com/twitter/http2/HttpCodecUtil.java
// static final int HTTP_CONNECTION_STREAM_ID = 0;


// Path: src/main/java/com/twitter/http2/HttpConnection.java
import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
import io.netty.channel.ChannelPromise;
import io.netty.util.internal.EmptyArrays;
import static com.twitter.http2.HttpCodecUtil.HTTP_DEFAULT_WEIGHT;
import static com.twitter.http2.HttpCodecUtil.HTTP_CONNECTION_STREAM_ID;

    PendingWrite getPendingWrite(int streamId) {
        if (streamId == HTTP_CONNECTION_STREAM_ID) {
            Node connection = streams.get(HTTP_CONNECTION_STREAM_ID);
            return getPendingWrite(connection);
        }

        Node stream = streams.get(streamId);
        StreamState state = stream == null ? null : stream.state;
        return state != null ? state.getPendingWrite() : null;
    }

    PendingWrite getPendingWrite(Node node) {
        PendingWrite e = null;
        if (node.state != null && node.state.getSendWindowSize() > 0) {
            e = node.state.getPendingWrite();
        }
        if (e == null) {
            for (Node child : node.children) {
                e = getPendingWrite(child);
                if (e != null) {
                    break;
                }
            }
        }
        return e;
    }

    PendingWrite removePendingWrite(int streamId) {
        Node stream = streams.get(streamId);
        StreamState state = stream == null ? null : stream.state;
        return state != null ? state.removePendingWrite() : null;