/** * @param BinaryTree $node * @return BinaryTree */ private function deleteNeitherChildIsNull(BinaryTree $node) { $value = $node->inOrderPredecessor()->value(); $node->setLeft($this->removeRecursive($value, $node->left())); $node->setValue($value); return $node; }