Move traversal logic within the graph classes