Generalized Stability Condition for Generalized and Doubly-Generalized LDPC Codes