A General Algorithmic Scheme for Combinatorial Decompositions with Application to Modular Decompositions of Hypergraphs