private function makeMatchSchedule(Tournament $tournament, MatchPlan $match)
 {
     // for QMatchPlan, group and team are undefined - use classification and litra instead
     if ($match instanceof QMatchPlan) {
         /* @var $match QMatchPlan */
         $ms = new QMatchSchedule();
         $ms->setTournament($tournament);
         $ms->setCategory($this->em->merge($match->getCategory()));
         $ms->setBranch('');
         $ms->setClassification($match->getClassification());
         $ms->setLitra($match->getLitra());
         $hr = new QMatchScheduleRelation();
         $hr->setBranch($match->getRelA()->getBranch());
         $hr->setClassification($match->getRelA()->getClassification());
         $hr->setLitra($match->getRelA()->getLitra());
         $hr->setRank($match->getRelA()->getRank());
         $hr->setAwayteam(false);
         $ms->addQMatchRelation($hr);
         $ar = new QMatchScheduleRelation();
         $ar->setBranch($match->getRelB()->getBranch());
         $ar->setClassification($match->getRelB()->getClassification());
         $ar->setLitra($match->getRelB()->getLitra());
         $ar->setRank($match->getRelB()->getRank());
         $ar->setAwayteam(true);
         $ms->addQMatchRelation($ar);
     } else {
         $ms = new MatchSchedule();
         $ms->setTournament($tournament);
         $ms->setGroup($this->em->merge($match->getGroup()));
         $hr = new MatchScheduleRelation();
         $hr->setTeam($this->em->merge($match->getTeamA()));
         $hr->setAwayteam(false);
         $ms->addMatchRelation($hr);
         $ar = new MatchScheduleRelation();
         $ar->setTeam($this->em->merge($match->getTeamB()));
         $ar->setAwayteam(true);
         $ms->addMatchRelation($ar);
     }
     return $ms;
 }