class PeerBucket {

    synchronized Peer replace(Peer last) {
        if (peers.isEmpty() || getLastPeer() != last) {
            // Entry has moved, don't replace it
            return null;
        }

        // Still the last entry
        if (replacements.isEmpty()) {
            dropPeer(last);
            return null;
        }

        // replaced dead node
        Peer peerToBeReplaced = lastPeerOf(replacements);
        deleteReplacement(peerToBeReplaced);
        dropPeer(last);
        addPeer(peerToBeReplaced);
        return peerToBeReplaced;
    }

      PeerBucket(int depth);

}