Branching structures are mechanically efficient in supporting large-span structures, such as free-form roofs. To support a roof with a specified geometry, we present a novel shape and topology optimization method to find the optimal branching structure in this paper. In the proposed method, the branching structure is modelled as a cablenet, while the reaction forces in z-direction from the roof are converted to the upward external loads at the branching structure. The force densities of the members are the design variables. The optimal branching structure can be obtained by minimizing one of the several types of objective functions, e.g., the sum of the strain energy, the sum of the absolute value of the internal axial forces, and the sum of the absolute value of the force densities, etc. The shape of the branching structure represented by the nodal coordinates is determined by solving the linear equilibrium equations in terms of force densities. The topology is optimized by removing the members with small axial forces and incorporating the closely spaced nodes. If the allowable stress is specified for the members, their cross-sectional areas can be directly calculated from the force densities and member lengths. Hence, it is very convenient to use force densities for simultaneously optimizing the cross-section, shape, and topology of a branching structure. Numerical examples show that this method can be easily applied to a 2D problem; however, for a 3D problem, the tolerances of the constraints on the reaction forces should be relaxed. It is also shown that considering the roof supports as variables is effective for finding an optimal shape of 3D branching structure supporting a free-form surface.