private Pair<Shape, LocalVariableStatement> getPEWithType(
String type, Diagram d) {
ILinkService ls = Graphiti.getLinkService();
EObject linked = null;
LocalVariableStatement modelObject = null;
//Find PE
Shape peShape = null;
for (Shape s : d.getChildren()) {
linked = ls.getBusinessObjectForLinkedPictogramElement(s);
if (linked instanceof LocalVariableStatement) {
LocalVariableStatement lvs = (LocalVariableStatement) linked;
if (lvs.getVariable().getTypeReference().getTarget() instanceof
ProcessingElementDefinition) {
ProcessingElementDefinition pd =
(ProcessingElementDefinition) lvs.getVariable(
).getTypeReference().getTarget();
if (pd.getName().equals(type)) {
peShape = s;
modelObject = lvs;
break;