code: public static RootContainer getRootContainer(final EntityContainer container) {
  	// Root must be identifable
  	if (!(container instanceof Identifiable)) {
  	    return null;
  	}
  
  	EntityContainer parent = container instanceof Entity ? ((Entity) container).getContainer() : null;
  	UUID rootID = null;
  
  	// Check not root
  	if (parent == null) {
  	    rootID = ((Identifiable) container).getID();
  	}
  	// Get parents root
  	else if (container instanceof Taggable) {
  	    final RootContainer parentRoot = ((Taggable) container).getSingletonTag(RootContainer.class);
  	    if (parentRoot != null) {
  		rootID = parentRoot.getValue();
  	    }
  	}
  
  	// Find root
  	if (rootID == null) {
  	    // Get top level entity
  	    while (parent instanceof Entity) {
  		final Entity e = (Entity) parent;
  		rootID = e.getID();
  		parent = e.getContainer();
  	    }
  	    // Container root (null, container or JALSE)
  	    if (!(parent instanceof Identifiable)) {
  		return null;
  	    }
  	}
  
  	return new RootContainer(rootID);
      }
docs: Gets or calculates the root container.
  
  @param container
  Container to check for.
  @return Root container for the supplied container.