public INamedEntity registerNodeTemplate(String name, INodeTemplate nodeType) {
   final NodeTemplate unnamed;
   if (nodeTypes.containsKey(name)) return null;
   if (nodeType instanceof NodeTemplate) unnamed = (NodeTemplate) nodeType;
   else {
     INodeType parentType = nodeType.baseType();
     if (parentType != null && !(parentType instanceof NodeTemplate))
       parentType = nodeTypes.get(((INamedEntity) parentType).name());
     unnamed =
         new NodeTemplate(
             (NodeType) parentType,
             nodeType.description(),
             nodeType.declaredProperties(),
             nodeType.declaredAttributes());
   }
   NamedNodeTemplate t = new NamedNodeTemplate(name, unnamed);
   nodeTemplates.put(name, t);
   return t;
 }
  public INamedEntity registerType(String name, IType type) {

    if (type instanceof ITypeStruct) {
      ITypeStruct struct = (ITypeStruct) type;
      final TypeStruct unnamed;
      if (nodeTypes.containsKey(name)) return null;
      if (struct instanceof TypeStruct) unnamed = (TypeStruct) struct;
      else {
        ITypeStruct parentType = struct.baseType();
        if (parentType != null && !(parentType instanceof TypeStruct))
          parentType = structTypes.get(((INamedEntity) parentType).name());
        unnamed =
            new TypeStruct(
                (TypeStruct) parentType, struct.description(), struct.declaredProperties());
      }
      NamedStruct t = new NamedStruct(name, unnamed);
      structTypes.put(name, t);
      return t;
    } else if (type instanceof ICoercedType) {
      coercedTypes.put(name, new NamedCoercedType(name, (ICoercedType) type));
    }
    return null;
  }