code: public static TreeDepth getTreeDepth(final EntityContainer container) {
  	// Must be identifiable to be in the tree
  	if (!(container instanceof Identifiable)) {
  	    return null;
  	}
  
  	EntityContainer parent = container instanceof Entity ? ((Entity) container).getContainer() : null;
  
  	// Check not root
  	if (parent == null) {
  	    return TreeDepth.ROOT;
  	}
  
  	// Increment parents depth
  	if (container instanceof Taggable) {
  	    final TreeDepth parentDepth = ((Taggable) container).getSingletonTag(TreeDepth.class);
  	    if (parentDepth != null) {
  		return parentDepth;
  	    }
  	}
  
  	int depth = 1;
  
  	// Calculate entity tree depth
  	while (parent instanceof Entity) {
  	    parent = ((Entity) parent).getContainer();
  	    depth++;
  	}
  
  	// Check if root is not null but identifable
  	if (parent instanceof Identifiable) {
  	    depth++;
  	}
  
  	return new TreeDepth(depth);
      }
docs: Gets the {@link TreeDepth} for the supplied container.
  
  @param container
  Container to get depth for.
  @return Tree depth tag.