Retrieval capabilities of hierarchical networks: from Dyson to Hopfield