avoid splicing in functions for better type inference. ref JuliaLang/julia#6626
preprocess DFS order for recovery
borrow code from Graphs.jl until available in julia release