def get_textnode_subtrees(html_tree,
                          xpath_to_text=TEXT_FINDER_XPATH):
    """A modification of get_sentence_xpath_tuples: some code was
    refactored-out, variable names are slightly different. This function
    does wrap the ltml.tree construction, so a file path, file-like
    structure, or URL is required.
    """

    try:
        xpath_finder = html_tree.getroot().getroottree().getpath
    except(AttributeError):
        xpath_finder = html_tree.getroottree().getpath

    nodes_with_text = html_tree.xpath(xpath_to_text)

    # Within the TextNodeSubTree construction, the ABSL is calculated
    # refer to eatiht_trees.py
    parentpaths_textnodes = [TextNodeSubTree(n, xpath_finder(n),
                                             n.xpath('.//text()'))
                             for n in nodes_with_text]

    if len(parentpaths_textnodes) is 0:
        raise Exception("No text nodes satisfied the xpath:\n\n" +
                        xpath_to_text + "\n\nThis can be due to user's" +
                        " custom xpath, min_str_length value, or both")

    return parentpaths_textnodes
A modification of get_sentence_xpath_tuples: some code was
    refactored-out, variable names are slightly different. This function
    does wrap the ltml.tree construction, so a file path, file-like
    structure, or URL is required.