This is the problem of finding the connected components inside an interval graph. You can implement the algorithms yourself, of you can use my graph data structure here:
http://sourceforge.net/projects/pynetwork/ The graph methods: createIntervalgGraph And: connectedComponents can probably solve your problem quite fast, algorithmically, and with few lines of code. If you need more help, then ask for it and I'll give the little code needed. Bear hugs, Bearophile -- http://mail.python.org/mailman/listinfo/python-list