private void mergeStacks(Collection sources, ASTNodeStack target) {
        logger.debug("Merging ...");
        
        Iterator iter = sources.iterator();
        while (iter.hasNext()) {
            Node pred = (Node) iter.next();
            dump(pred.stack, "Stack for " + pred);
        }
        
        
        int stackSize = -1;
        //String msg = "";
        // Find the common size of all source stacks.
        iter = sources.iterator();
        while (iter.hasNext()) {
            Node pred = (Node) iter.next();
            //msg += pred + ", ";
            if (stackSize == -1) {
                stackSize = pred.stack.size(); 
            } else if (stackSize != pred.stack.size()){
                dump(sources);
                throw new RuntimeException("Stack size mismatch");
            }
        }

        for (int index=0; index < stackSize; index++) {
            Object obj = stacksIdentical(sources, index);
            if (obj instanceof Expression) {
                target.add((Expression) ((Expression) obj).clone());
                logger.debug("\tIdentical: " + obj);
            } else {
                // Generate variable binding tempX.
                VariableBinding vb = methodDecl.createAnonymousVariableBinding((Type) obj, true);
                // Append binding to target stack.
                target.add(vb);
                
                iter = sources.iterator();
                while (iter.hasNext()) {
                    Node node = (Node) iter.next();
                    Expression expr = (Expression) node.stack.get(index);
                    // Generate assignment tempX = expr.
                    Assignment a = new Assignment(Assignment.Operator.ASSIGN);
                    a.setLeftHandSide((VariableBinding) vb.clone());
                    if (expr instanceof VariableBinding) expr = (VariableBinding) expr.clone();
                    a.setRightHandSide(expr);
                    // Append assignment to source node.
                    node.block.appendChild(a);
                }
                logger.debug("\t" + vb.getName());
            }
        }
        logger.debug("... Merging stacks");
    }