misha.korolcov,
<script>
const grop = [
{ name: 'merseded', groupName: 'avto', idParent: '11' },
{name: 'bmv', groupName: 'avto', idParent: '20' }
];
const city = [{name: 'test1', idMain: '11'},
{name: 'test2', idMain: '11'},
{name: 'test3', idMain: '20'},
{name: 'test4', idMain: '11'}];
const resaltCity = grop.map(obj => (obj.children = city.filter(({idMain}) => idMain == obj.idParent), obj));
document.write(`<pre>${JSON.stringify(resaltCity, "", 4)}</pre>`)
</script>
темы создавать здесь
Общие вопросы Javascript