void build(Node input, Node output) {
        if (input==null) return;
        
        if (isFreeTextChunk(input)) {
            // collapse sibling freetext chunks and eventually compute a containing bb
            StringBuffer freetext = new StringBuffer();
            Set bboxes = new HashSet();
            Node node = input;
            do  {
                collapseFreetext(node, freetext, bboxes);
                node = node.getNextSibling();
            } while (node!=null && isFreeTextChunk(node));
            Box containingBox = Box.getContainingBox(bboxes);
            if (containingBox!=null) {
                // encode bb as comment
                output.appendChild(this.result.createComment(Box.encode(containingBox)));
            }
            // freetext chunk in a new freetext node
            output.appendChild(this.result.createTextNode(freetext.toString()));
            // then visit next sibling
            build(node,output);
        }
        else {
            Node clone = this.result.importNode(input,false);
            output.appendChild(clone);
            // first visit childs
            build(input.getFirstChild(), clone);
            // then visit siblings
            build(input.getNextSibling(),output);
        }
    }