Object modelElement = null;
for (final Iterator iterator = resourceSet.getResources().iterator();
iterator.hasNext() && modelElement == null;)
{
final Resource resource = (Resource)iterator.next();
final Package model =
(Package)EcoreUtil.getObjectByType(
resource.getContents(),
UML2Package.eINSTANCE.getPackage());
if (model != null)
{
for (final TreeIterator elementIterator = model.eAllContents();
elementIterator.hasNext() && modelElement == null;)
{
final Object object = elementIterator.next();
if (pred.evaluate(object))
{