key = $key; $this->value = $value; // Set all node pointers to null initially $this->left = null; $this->right = null; $this->parent = null; } public function isLeaf(): bool { return $this->left === null && $this->right === null; } public function isRoot(): bool { return $this->parent === null; } }