code: public <T extends IBase> List<T> getAllPopulatedChildElementsOfType(IBaseResource theResource, final Class<T> theType) {
  		final ArrayList<T> retVal = new ArrayList<T>();
  		BaseRuntimeElementCompositeDefinition<?> def = myContext.getResourceDefinition(theResource);
  		visit(new IdentityHashMap<Object, Object>(), theResource, theResource, null, null, def, new IModelVisitor() {
  			@SuppressWarnings("unchecked")
  			@Override
  			public void acceptElement(IBaseResource theOuterResource, IBase theElement, List<String> thePathToElement, BaseRuntimeChildDefinition theChildDefinition, BaseRuntimeElementDefinition<?> theDefinition) {
  				if (theElement == null || theElement.isEmpty()) {
  					return;
  				}
  
  				if (theType.isAssignableFrom(theElement.getClass())) {
  					retVal.add((T) theElement);
  				}
  			}
  		});
  		return retVal;
  	}
docs: Returns a list containing all child elements (including the resource itself) which are <b>non-empty</b> and are either of the exact type specified, or are a subclass of that type.
  <p>
  For example, specifying a type of {@link StringDt} would return all non-empty string instances within the message. Specifying a type of {@link IResource} would return the resource itself, as
  well as any contained resources.
  </p>
  <p>
  Note on scope: This method will descend into any contained resources ({@link IResource#getContained()}) as well, but will not descend into linked resources (e.g.
  {@link BaseResourceReferenceDt#getResource()}) or embedded resources (e.g. Bundle.entry.resource)
  </p>
  
  @param theResource The resource instance to search. Must not be null.
  @param theType     The type to search for. Must not be null.
  @return Returns a list of all matching elements