public function getDifferentSosaCountUpToGeneration($gen){
        if(!$this->is_setup) return 0;
        return Database::prepare(
            'SELECT COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' .
            ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'.
            ' AND majs_gen <= :gen')
        ->execute(array(
                'tree_id' => $this->tree->getTreeId(), 
                'user_id' => $this->user->getUserId(),
                'gen' => $gen 
        ))->fetchOne() ?: 0;
    }