public function getSosaListAtGeneration($gen){
        if(!$this->is_setup) return array();
        if(!$this->sosa_list_by_gen)
            $this->sosa_list_by_gen = array();
        
        if($gen){
            if(!isset($this->sosa_list_by_gen[$gen])){
                $this->sosa_list_by_gen[$gen] = Database::prepare(
                    'SELECT majs_sosa AS sosa, majs_i_id AS indi'.
                    ' FROM `##maj_sosa`'.
                    ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'.
                    ' AND majs_gen = :gen'.
                    ' ORDER BY majs_sosa ASC')
                ->execute(array(
                    'tree_id' => $this->tree->getTreeId(),
                    'user_id' => $this->user->getUserId(),
                    'gen' => $gen
                ))
                ->fetchAssoc();
            }
            return $this->sosa_list_by_gen[$gen];
        }
        return array();
    }