For example, with C-h k I can ask to Emacs "what does C-right do in this buffer?". If the current buffer was a Lisp buffer in my setup, Emacs would answer paredit-forward-slurp-sexp. From that, I can guess that the binding of C-right to paredit-forward-slurp-sexp is from the paredit mode map because the command name is prefixed by paredit, but that's a heuristic. How can I do that programmatically, i.e., how can I ask "where is the binding of C-right in this buffer coming from?"
Is writing a function that in this case checks current global map, current major mode map, paredit-mode-map, paredit-forward-mode-map, paredit-forward-slurp-mode-map, paredit-forward-slurp-sexp-mode-map the only way?