public IREntity findEntity(RName name) throws RulesException{
RName entityname = name.getEntityName(); // If the RName does not spec an Enttiy Name
if(entityname == null){ // then we simply look for the RName in each
for(int i=entitystkptr-1;i>=0;i--){ // entity on the Entity Stack.
IREntity e = entitystk[i];
if(e.containsAttribute(name)) return e;
}
}else{ // Otherwise, we insist that the Entity name
for(int i=entitystkptr-1;i>=0;i--){ // match as well as insist that the Entity
IREntity e = entitystk[i]; // have an attribute that matches this name.
if(e.getName().equals(entityname)){