Set roots = new HashSet(); for (Iterator it = frames.iterator(); it.hasNext(); ) { QFrame f = (QFrame) it.next(); roots.add(f.getRoot()); }    for(QFrame c = frame.getContainer(); c != null; c = c.getContainer()) { QFrame root = c.getRoot(); if (roots.contains(root)) { return root; } }  return null;
return frame.getContainer();
    QFrame getConstraining(QFrame frame) {        List conds = frame.getConditions();        List values = new ArrayList();        Set frames = new HashSet();        for (Iterator it = conds.iterator(); it.hasNext(); ) {            Expression e = (Expression) it.next();            addConstraining(e, frame, values, frames);        }        if (!frame.isConstrained(values)) {            return null;        }        Set roots = new HashSet();        for (Iterator it = frames.iterator(); it.hasNext(); ) {            QFrame f = (QFrame) it.next();            roots.add(f.getRoot());        }        // if there is more than one root we need to pick the most        // nested frame        for(QFrame c = frame.getContainer(); c != null; c = c.getContainer()) {            QFrame root = c.getRoot();            if (roots.contains(root)) {                return root;            }        }        return null;    }