The look-elsewhere effect from a unified Bayesian and frequentist perspective