core.c: Add support for preserving original tree formation

In case of SM failover/handover, the new master SM receives
join requests from already running SSA nodes that were
already connected to some parent node in distribution tree.

The join mechanism will first try to reuse the same parent
that the node is already connected to, and in case of no
success after a certain amount of time (join_timeout) new
parent will be assigned.

Note: Currently "parent reuse" is valid for pure ACCESS nodes
only since distribution nodes are always assigned with core
layer as parent and acm nodes that send rejoin requests are
only those that were connected directly to core - we will try
to reconnect them to some access layer instead.

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