From d844ec06407b139334de2e770285500f238b96cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Sat, 28 Jan 2023 18:52:39 +0100 Subject: [PATCH] Fix: Return array with node from getNeighborsAndSelf() when node is root --- src/Node/NodeTrait.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Node/NodeTrait.php b/src/Node/NodeTrait.php index 8b7672d..3a6a4d2 100644 --- a/src/Node/NodeTrait.php +++ b/src/Node/NodeTrait.php @@ -129,6 +129,12 @@ public function getNeighbors(): array public function getNeighborsAndSelf(): array { + if (null === $this->parent) { + return [ + $this, + ]; + } + return $this->getParent()->getChildren(); }