Preheat oven to 350 degrees. Butter 13X6 inch oval baking dish. Slice sweet potatoes into 1/4" thick slices. Melt butter in heavy large skillet over medium heat. Add onions and saute until tender, about 10 minutes. Toss apples with flour in medium bowl. Arrange half of sweet potatoes in bottom of prepared dish. Top with half of apple slices. Arrange remaining potatoes and then remaining apples. Cover with sauteed onions. Pour stock over all. Bake until sweet potatoes are tender, about 45 minutes. Maintain oven temperature. Mix breadcrumbs, cheese and bacon (crumbled) in small bowl. Sprinkle mixture over gratin. Bake an additional 20 minutes. Preheat broiler. Broil until topping browns. (This has not been necessary any time I have made this recipe as the oven browns the topping just fine for me). Cool 5 minutes and serve. Substitution: Use Butternut or Acorn squash instead of the sweet potatoes.