original_string: protected function _removeFromTree($node)
      {
          $config = $this->getConfig();
          $left = $node->get($config['left']);
          $right = $node->get($config['right']);
          $parent = $node->get($config['parent']);
  
          $node->set($config['parent'], null);
  
          if ($right - $left == 1) {
              return $this->_table->save($node);
          }
  
          $primary = $this->_getPrimaryKey();
          $this->_table->updateAll(
              [$config['parent'] => $parent],
              [$config['parent'] => $node->get($primary)]
          );
          $this->_sync(1, '-', 'BETWEEN ' . ($left + 1) . ' AND ' . ($right - 1));
          $this->_sync(2, '-', "> {$right}");
          $edge = $this->_getMax();
          $node->set($config['left'], $edge + 1);
          $node->set($config['right'], $edge + 2);
          $fields = [$config['parent'], $config['left'], $config['right']];
  
          $this->_table->updateAll($node->extract($fields), [$primary => $node->get($primary)]);
  
          foreach ($fields as $field) {
              $node->setDirty($field, false);
          }
  
          return $node;
      }
code: protected function _removeFromTree($node)
      {
          $config = $this->getConfig();
          $left = $node->get($config['left']);
          $right = $node->get($config['right']);
          $parent = $node->get($config['parent']);
  
          $node->set($config['parent'], null);
  
          if ($right - $left == 1) {
              return $this->_table->save($node);
          }
  
          $primary = $this->_getPrimaryKey();
          $this->_table->updateAll(
              [$config['parent'] => $parent],
              [$config['parent'] => $node->get($primary)]
          );
          $this->_sync(1, '-', 'BETWEEN ' . ($left + 1) . ' AND ' . ($right - 1));
          $this->_sync(2, '-', "> {$right}");
          $edge = $this->_getMax();
          $node->set($config['left'], $edge + 1);
          $node->set($config['right'], $edge + 2);
          $fields = [$config['parent'], $config['left'], $config['right']];
  
          $this->_table->updateAll($node->extract($fields), [$primary => $node->get($primary)]);
  
          foreach ($fields as $field) {
              $node->setDirty($field, false);
          }
  
          return $node;
      }
code_tokens: protected function _removeFromTree ( $ node ) { $ config = $ this -> getConfig ( ) ; $ left = $ node -> get ( $ config [ 'left' ] ) ; $ right = $ node -> get ( $ config [ 'right' ] ) ; $ parent = $ node -> get ( $ config [ 'parent' ] ) ; $ node -> set ( $ config [ 'parent' ] , null ) ; if ( $ right - $ left == 1 ) { return $ this -> _table -> save ( $ node ) ; } $ primary = $ this -> _getPrimaryKey ( ) ; $ this -> _table -> updateAll ( [ $ config [ 'parent' ] => $ parent ] , [ $ config [ 'parent' ] => $ node -> get ( $ primary ) ] ) ; $ this -> _sync ( 1 , '-' , 'BETWEEN ' . ( $ left + 1 ) . ' AND ' . ( $ right - 1 ) ) ; $ this -> _sync ( 2 , '-' , "> {$right}" ) ; $ edge = $ this -> _getMax ( ) ; $ node -> set ( $ config [ 'left' ] , $ edge + 1 ) ; $ node -> set ( $ config [ 'right' ] , $ edge + 2 ) ; $ fields = [ $ config [ 'parent' ] , $ config [ 'left' ] , $ config [ 'right' ] ] ; $ this -> _table -> updateAll ( $ node -> extract ( $ fields ) , [ $ primary => $ node -> get ( $ primary ) ] ) ; foreach ( $ fields as $ field ) { $ node -> setDirty ( $ field , false ) ; } return $ node ; }
docstring: Helper function containing the actual code for removeFromTree
  
  @param \Cake\Datasource\EntityInterface $node The node to remove from the tree
  @return \Cake\Datasource\EntityInterface|false the node after being removed from the tree or
  false on error
docstring_tokens: Helper function containing the actual code for removeFromTree