Refactor first depth first pass to run iteratively so as to not exceed max stack size
Rename file