Let's say I have a way of identifying (through name or number) a buffer which is already open in a window somewhere. How can I focus on the window that hosts said buffer? Can this be generalizable so that I can find this window even if it lives in another tab?
You can use the functions
win_gotoid as follows:
let wins = win_findbuf(bufnr('name')) call win_gotoid(wins)
This goes to the "first" buffer that contains the window, and the list will be ordered by tab and window number. Also left as an exercise to handle the error case where no window contains your buffer.