There are applications in the sheet metal, paperboard, packaging and various other industries for the computer-aided design of flat patterns for folding into some desired 3D folded structure made of piecewise flat faces. This paper describes a methodology for the automatic development of flat patterns for any given folded structure based on enumerating all possible spanning trees of the face adjacency graph (the graph that represents the connectivity among the faces of the structure) since any spanning tree represents a potential topological unfolding of that structure. Complications found in non-manifold structures, such as where more than two faces are joined at one common edge, are also addressed in this work by way of recognizing topologically invalid spanning trees. Furthermore, a strategy is also developed to detect overlapping of faces within the pattern purely by checking its topology defined in the spanning tree, without first having to geometrically construct the pattern layout. Finally, three measures of compactness are adopted as the optimality criteria for the methodology to output flat pattern results ranked according to their compactness. The procedure is implemented as a computer program and applied to six example structures in this paper to illustrate the capabilities of the methodology.