/**
  * @return \yii\db\ActiveQuery
  */
 protected function getSortableQuery()
 {
     switch ($this->operation) {
         case self::OPERATION_PREPEND_TO:
         case self::OPERATION_APPEND_TO:
             $path = $this->node->getAttribute($this->pathAttribute);
             $depth = $this->node->getAttribute($this->depthAttribute) + 1;
             break;
         case self::OPERATION_INSERT_BEFORE:
         case self::OPERATION_INSERT_AFTER:
             $path = $this->node->getParentPath();
             $depth = $this->node->getAttribute($this->depthAttribute);
             break;
         default:
             $path = $this->getParentPath();
             $depth = $this->owner->getAttribute($this->depthAttribute);
     }
     $tableName = $this->owner->tableName();
     return $this->owner->find()->andWhere($this->treeCondition())->andWhere($path !== null ? ['like', "{$tableName}.[[{$this->pathAttribute}]]", $this->getLike($path), false] : '1=0')->andWhere(["{$tableName}.[[{$this->depthAttribute}]]" => $depth]);
 }