Tengo un servicio que me devuelve un objeto como este:
[
{id: 1, name: 'Pedro', city:1, state: 1, country: 1},
{id: 2, name: 'Juan', city:12, state: 2, country: 1},
{id: 3, name: 'Ana', city:10, state: 5, country: 1},
{id: 4, name: 'Diego', city:7, state: 9, country: 1},
{id: 5, name: 'Jose', city:4, state: 2, country: 1},
{id: 6, name: 'David', city:7, state: 9, country: 1},
{id: 7, name: 'Adriana', city:1, state: 1, country: 1},
{id: 8, name: 'Jorge', city:15, state: 2, country: 1},
];
¿Cómo crear un objeto que quede con la siguiente estructura:
countries >> states >> cities >> persons
country
y así sucesivamente?