get_connected_nodes function

Returns all the node connected directly or indirectly to a set of nodes