private void endRegion() throws RegionExistsException {
    RegionCreation region = (RegionCreation) stack.pop();
    boolean isRoot = false;
    if (stack.isEmpty()) {
      isRoot = true;
    } else if (!(stack.peek() instanceof RegionCreation)) {
      isRoot = true;
    }
    if (isRoot) {
      cache.addRootRegion(region);
    } else {
      RegionCreation parent = (RegionCreation) stack.peek();
      parent.addSubregion(region.getName(), region);
    }
  }
After popping the current <code>RegionCreation</code> off the stack, if the element on top of
the stack is a <code>RegionCreation</code>, then it is the parent region.
geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/CacheXmlParser.java