/**
  * @return \yii\db\ActiveQuery
  */
 public static function findLocation($input)
 {
     if (!is_array($input)) {
         return null;
     }
     $listTypes = ArrayHelper::map(static::$types, 'tag', 'id');
     $filtered = [];
     foreach ($input as $inputKey => $inputValue) {
         if (isset($listTypes[$inputKey])) {
             $filtered[$inputKey] = $inputValue;
         }
     }
     if (empty($filtered)) {
         return null;
     }
     $counter = 0;
     $locationTable = Location::tableName();
     $query = static::find();
     foreach ($filtered as $type => $name) {
         if ($counter === 0) {
             $query->andWhere(['and', [$locationTable . '.type_id' => $listTypes[$type]], [$locationTable . '.name' => $name]]);
         } else {
             $linksTable = 'link' . strval($counter);
             $query->leftJoin(LocationLinks::tableName() . ' AS ' . $linksTable, $linksTable . '.lower_id = ' . $locationTable . '.id');
             $locationTable = 'loc' . strval($counter);
             $query->leftJoin(Location::tableName() . ' AS ' . $locationTable, $locationTable . '.id = ' . $linksTable . '.upper_id');
             $query->andWhere(['and', [$locationTable . '.type_id' => $listTypes[$type]], [$locationTable . '.name' => $name]]);
         }
         $counter++;
     }
     //        $result = $query->all();
     //        if( is_array($result) && (count($result) == 1) ) return $result[0];
     //        return $result;
     return $query;
 }