For example I have an array
[
{
login: user1,
parent: ''
},
{
login: user2,
parent: user1
},
{
login: user3,
parent: user1
},
{
login: user4,
parent: user3
}
]
I need to count how many children user1 has and set him property childrenAmount. Including that one user4 that is user1's grandchild too and deep of this tree can be different.