How am I supposed to implement an ever growing FIFO queue in OpenCL?

I have a queue that originally has a predefined size, but my kernel is supposed to:

- dequeue the first item,
- see if this item needs "subdivision".
-> if it does not, stop processing the item, and move on to the next one in a FIFO fashion
-> if it does, then subdivide, eg. generate 2 new items and enqueue them.

Would somebody have a reference for me for the implementation of a FIFO queue in OpenCL?