AnAction (@NotNull AnAction action) { while (action instanceof ActionWithDelegate<?>) { Object delegate = ((ActionWithDelegate<?>)action).getDelegate(); if (delegate instanceof AnAction) { action = (AnAction)delegate; } else { return action; } } return action; }