diff --git a/vendor/magento/module-versions-cms/Model/ResourceModel/Hierarchy/Node.php b/vendor/magento/module-versions-cms/Model/ResourceModel/Hierarchy/Node.php
index 2d7328cfe43f..f36db2e134dd 100644
--- a/vendor/magento/module-versions-cms/Model/ResourceModel/Hierarchy/Node.php
+++ b/vendor/magento/module-versions-cms/Model/ResourceModel/Hierarchy/Node.php
@@ -299,8 +299,11 @@ public function updateRequestUrlsForTreeByXpath($xpath)
             'node_table.page_id=page_table.' . $entityMetadata->getIdentifierField(),
             ['page_identifier' => 'identifier']
         )->where(
-            'xpath LIKE ? OR xpath = ?',
+            'xpath LIKE ?',
             $xpath . '/%'
+        )->orWhere(
+            'xpath = ?',
+            $xpath
         )->group(
             'node_table.node_id'
         )->order(
@@ -588,7 +591,6 @@ public function setTreeIsBrief($brief)
     public function getTreeSlice($object, $up = 0, $down = 0)
     {
         $tree = [];
-        $parentId = $object->getParentNodeId();
 
         if ($this->_treeMaxDepth > 0 && $object->getLevel() > $this->_treeMaxDepth) {
             return $tree;
@@ -623,7 +625,6 @@ public function getTreeSlice($object, $up = 0, $down = 0)
          */
         $connection = $this->getConnection();
         if ($parentIds) {
-            $parentId = $parentIds[count($parentIds) - 1];
             if ($this->_treeIsBrief) {
                 $where = $connection->quoteInto($this->getMainTable() . '.node_id IN (?)', $parentIds);
                 // Collect neighbours if there are no children
