Structure trees, networks and almost invariant sets