core.c: Next version of distribution tree formation algorothm

Rather than merely choosing last register node at appropriate level,
this version balances the children across the possible parents
based on the node type of the child (joining node).

This version removes most of the distribution tree bringup order
issues.

There will be subsequent improved versions of this algorithm.

Also, there will be a subsequent minor patch to not increment
number of children when the node rejoins (without intervening leave).

Signed-off-by: Hal Rosenstock <hal@mellanox.com>