Variable variable = ((ForEach)container).getCounterName();
if (variable != null && variable.getName().equals(variableName)) {
return variable;
}
} else {
Variables variables = null;
if (container instanceof Process)
variables = ((Process)container).getVariables();
else if (container instanceof Scope)
variables = ((Scope)container).getVariables();
if (variables != null) {
List<Object> list = new ArrayList<Object>();
// check all BPEL variables if anyone has the correct variable name
list.addAll(variables.getChildren());
list.addAll(variables.getExtensibilityElements());
for (Object n : list) {
if (n instanceof Variable) {
Variable variable = (Variable) n;
String name = variable.getName();