/**
  * Returns {@code true} if the given key has already been registered. This is used to prevent
  * reentrant metadata registration (and cycles).
  */
 public boolean isRegistered(ElementKey<?, ?> key) {
   RootKey rootKey = Schema.getRootKey(key);
   ElementMetadataRegistryBuilder elementRegistry = elements.get(rootKey);
   if (elementRegistry != null) {
     return elementRegistry.isRegistered(null, key, null);
   }
   return false;
 }