Implemented depth first traversal, passes test