boolean (@Nullable Object input) { if (input == null) { return false; } if (myFilter == null) { return true; // No need to check } if (!(input instanceof LookupElement)) { return true; // Do not know how to check } final PyElement pyElement = PyUtil.as(((LookupElement)input).getPsiElement(), PyElement.class); if (pyElement == null) { return false; } return myFilter.process(pyElement); }