Added a recursive DFS-method which seemed to solve our problem