Linking tree shapes to the spread of infection using generalised branching processes