'Make sequences of children pointing to the same content file into
children of the first node referencing that file.'

def autolayer(self):

    prev = None
    for node in list(self.nodes):
        if (prev and (urldefrag(prev.href)[0] == urldefrag(node.href)[0])):
            self.nodes.remove(node)
            prev.nodes.append(node)
        else:
            prev = node
