added check to assert network is a tree