'Find the tag at which to split the tree rooted at `root`.
Search order is:
* Heading tags
* <div> tags
* <pre> tags
* <hr> tags
* <p> tags
* <br> tags
* <li> tags
We try to split in the "middle" of the file (as defined by tag counts.'

def find_split_point(self, root):

    def pick_elem(elems):
        if elems:
            elems = [i for i in elems if (i.get(SPLIT_POINT_ATTR, '0') != '1')]
            if elems:
                i = int(math.floor((len(elems) / 2.0)))
                elems[i].set(SPLIT_POINT_ATTR, '1')
                return elems[i]
    for path in ('//*[re:match(name(),    "h[1-6]",    "i")]', '/h:html/h:body/h:div', '//h:pre', '//h:hr', '//h:p', '//h:div', '//h:br', '//h:li'):
        elems = root.xpath(path, namespaces=NAMESPACES)
        elem = pick_elem(elems)
        if (elem is not None):
            try:
                XPath(elem.getroottree().getpath(elem))
            except:
                continue
            return (elem, True)
    return (None, True)
