The $L^2$-(co)homology of groups with hierarchies