Hierarchical Decomposition and Analysis for Generalized Planning