private static boolean canBeRoot(@Nullable PsiElement element, @NotNull SearchScope migrationScope) {
    if (element == null) return false;
    return element.isValid() &&
           element.isPhysical() &&
           PsiSearchScopeUtil.isInScope(migrationScope, element);
  }
private static boolean canBeRoot(@Nullable PsiElement element, @NotNull SearchScope migrationScope)