original_string: public function validateByOnlyOne($nodeType, TreeInterface $tree)
      {
          if (!$nodeType) {
              return true;
          }
  
          $config = $this->getNodeTypeConfig($nodeType);
          if (null === $config) {
              return false;
          }
  
          if ($config->isOnlyOne()) {
              return !in_array($nodeType, $this->nodeManager->findExistingNodeTypes($tree));
          }
  
          return true;
      }
code: public function validateByOnlyOne($nodeType, TreeInterface $tree)
      {
          if (!$nodeType) {
              return true;
          }
  
          $config = $this->getNodeTypeConfig($nodeType);
          if (null === $config) {
              return false;
          }
  
          if ($config->isOnlyOne()) {
              return !in_array($nodeType, $this->nodeManager->findExistingNodeTypes($tree));
          }
  
          return true;
      }
code_tokens: public function validateByOnlyOne ( $ nodeType , TreeInterface $ tree ) { if ( ! $ nodeType ) { return true ; } $ config = $ this -> getNodeTypeConfig ( $ nodeType ) ; if ( null === $ config ) { return false ; } if ( $ config -> isOnlyOne ( ) ) { return ! in_array ( $ nodeType , $ this -> nodeManager -> findExistingNodeTypes ( $ tree ) ) ; } return true ; }
docstring: Validate by only one.
  
  @param string $nodeType
  @param TreeInterface $tree
  
  @return bool
docstring_tokens: Validate by only one .