Utility function for building the branching system.