Expanders, rank and graphs of groups