public void handleEndTag(Tag t, int pos) {
            int ptr;
            TreeNode[] branches;
            int length = stack.size();
            for(ptr = length - 1; ptr >= 0 && ! ((String)((TreeNode)(stack.elementAt(ptr))).data).equals(t.toString()); ptr--) {
                // do nothing
            } // end of for-loop
            if (length - ptr - 1 > 0) {
                branches = new TreeNode[length - ptr - 1];
            } else {
                branches = null;
            } // end of if-then-else
            for(int index = 0; index < length - ptr - 1; index++) {
                branches[index] = (TreeNode)(stack.pop());
            } // end of for-loop
            if (ptr != length && length > 0) {
                // Let us not forget to remove the old start tag!
                stack.pop();
            } // end of if-then-else
            TreeNode node = new TreeNode(t.toString());
            if (branches != null) {
                node.branch = branches;
            } // end of if-then
            stack.push(node);
        } // end of method handleEndTag