Catch cyclic dependency graphs and give a nice error instead of running out of stack