Return the window specified by WINDOW. If WINDOW is nil, return the selected window. Otherwise, if WINDOW is a live or an internal window, return WINDOW; if LIVE-ONLY is non-nil, return WINDOW for a live window only. Otherwise, signal an error.