/** * Returns true if both this node and $otherNode are root, leaf or child (same tree scope) * * @param TreeModel $otherNode * * @return bool */ public function inSameScope(TreeModel $otherNode) { if ($this->isLeaf()) { return $otherNode->isLeaf(); } elseif ($this->isRoot()) { return $otherNode->isRoot(); } elseif ($this->isChild()) { return $otherNode->isChild(); } else { return false; } }