Basically finished spanning tree method

Still has infinite loop problem however