protected function getPlacesHierarchyFromData() {
        $nb_levels = 0;
        
        //Select all '2 PLAC ' tags in the file and create array
        $places_list=array();
        $ged_data = Database::prepare(
            'SELECT i_gedcom AS gedcom'.
            ' FROM `##individuals`'.
            ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'.
            ' UNION ALL'.
            'SELECT f_gedcom AS gedcom'.
            ' FROM `##families`'.
            ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id'
        )->execute(array(
            'gedcom' => '%\n2 PLAC %',
            'gedcom_id' => $this->tree->getTreeId()            
        ))->fetchOneColumn();
        foreach ($ged_data as $ged_datum) {
            $matches = null;
            preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches);
            foreach ($matches[1] as $match) {
                $places_list[$match]=true;
            }
        }
        
        // Unique list of places
        $places_list=array_keys($places_list);
        
        //sort the array, limit to unique values, and count them
        usort($places_list, array('I18N', 'strcasecmp'));
        
        //calculate maximum no. of levels to display
        $has_found_good_example = false;
        foreach($places_list as $place){
            $levels = explode(",", $place);
            $parts = count($levels);
            if ($parts >= $nb_levels){
                $nb_levels = $parts;
                if(!$has_found_good_example){
                    $random_place = $place;
                    if(min(array_map('strlen', $levels)) > 0){
                        $has_found_good_example = true;
                    }
                }
            }
        }
        
        return array_reverse(array_map('trim',explode(',', $random_place)));
    }