Q.Fill a hole in a tree
Where a big branch comes off of the trunk of a large oak, there is a hole that fills up with water and debris. What can I do about it? I’m afraid it’s going to rot and the branch will eventually fall

I've seen that filling with hole with some expanding foam, like I'd use for a hole in the wall of my home, would that be beneficial for my concern?

This article will help you.
https://www.gardeningknowhow.com/ornamental/trees/tgen/patching-tree-hole.htm