/**
  * Checks a group's children against a list of allowed structures for the group (ie those
  * mentioned in the profile with usage other than X). Returns a list of exceptions representing
  * structures that appear in the message but are not supposed to.
  */
 protected List<ValidationException> checkForExtraStructures(
     Group group, List<String> allowedStructures) {
   List<ValidationException> exList = new ArrayList<>();
   for (String childName : group.getNames()) {
     if (!allowedStructures.contains(childName)) {
       try {
         for (Structure rep : group.getAll(childName)) {
           profileViolatedWhen(!isEmpty(rep), exList, STRUCTURE_NOT_DEFINED_IN_PROFILE, childName);
         }
       } catch (HL7Exception he) {
         exList.add(new ValidationException("Problem checking profile:" + he.getMessage()));
       }
     }
   }
   return exList;
 }
  private void populateFully(Group theA01) throws HL7Exception {
    for (String nextName : theA01.getNames()) {
      if (nextName.equals("MSH")) {
        continue;
      }

      Structure nextStruct = theA01.get(nextName);
      if (nextStruct instanceof Segment) {
        Segment seg = (Segment) nextStruct;
        for (int i = 1; i <= seg.numFields(); i++) {
          populateFully(seg.getField(i, 0));
        }
      } else {
        populateFully((Group) nextStruct);
      }
    }
  }