Multiple taxonomies as hierarchy php and wordpress

i have 3 taxonomies for example:

Country
City
Person

All taxonomies are independent and at the same level, i have 4 posts with different terms:

Read More
Post 1 => Country: Italy
Post 2 => City: Rome
Post 3 => Person: Mario Rossi
Post 4 => Italy, Rome and Mario Rossi
Post 5 => No Taxonomies

Now all that i need to get a return as an hirechial and multidimensional array like this, started from the posts:

Array(
      "Italy" => array(
            "Rome" => array(
                  "Mario Rossi" => array(
                        "Post 1" => array(.....),
                        "Post 2" => array(.....),
                        "Post 3" => array(.....),
                        "Post 4" => array(.....)
                  )
                  "No Person" => array(
                        "Post 1" => array(.....),
                        "Post 2" => array(.....),
                        "Post 4" => array(.....)
                  )
            ),
            "No City" => array(
                  "Mario Rossi" => array(
                        "Post 1" => array(.....),
                        "Post 3" => array(.....),
                        "Post 4" => array(.....),
                  ),
                  "No Person" => array(
                        "Post 1" => array(.....),
                        "Post 4" => array(.....)
                  )                  
            )
      )
      "No Nation" => array(
            "Rome" => array(
                  "Mario Rossi" => array(
                        "Post 2" => array(.....),
                        "Post 3" => array(.....),
                        "Post 4" => array(.....),
                  ),
                  "No Person" => array(
                        "Post 2" => array(.....),
                        "Post 4" => array(.....),
                  )
            ),
            "No City" => array(
                  "Mario Rossi" => array(
                        "Post 3" => array(.....),
                        "Post 4" => array(.....),
                  ),
            "No Person" => array(
                    "Post 5" => array(......)
                  )
            )
      )
);

How can i do?

Your help are really appreciated.

Have a nice day.

Related posts