Some structural tweaks[2] +new isomorphism alg.

Better tree isomorphism algorithm and some stupid structural tweaks.
Removed unneeded imports.
Added set_stack for fast lookups.
Added check whether graph is undirected.

Tree algorithms work only on undirected graphs.