private boolean isFreeTextChunk(Node node) {
        int type = node.getNodeType();
        switch (type) {
            case Node.TEXT_NODE:
                return true;
            case Node.COMMENT_NODE:
                return true;  // comments do not prevent from collapsing freetext
            case Node.ELEMENT_NODE:
                NodeList children = node.getChildNodes();
                if (children.getLength()==0) {
                    return isVariantTag(node); /* leaf tag */
                }
                else if (!isPresentationTag(node)) {
                    return false;
                }
                //it is one of freetext tags; consider it  a chunk
                //of freetext iff all children are freetext chunks
                else return allChildrenAreFreeTextChunks(node);
        }
        return false; //all other types of DOM node types stop freetext collapsing
    }