diff --git a/python/src/com/jetbrains/python/psi/resolve/QualifiedNameFinder.java b/python/src/com/jetbrains/python/psi/resolve/QualifiedNameFinder.java index 387b8b4e217f..04029133f240 100644 --- a/python/src/com/jetbrains/python/psi/resolve/QualifiedNameFinder.java +++ b/python/src/com/jetbrains/python/psi/resolve/QualifiedNameFinder.java @@ -85,13 +85,7 @@ public class QualifiedNameFinder { @Nullable private static QualifiedName shortestQName(@NotNull List qNames) { - QualifiedName result = null; - for (QualifiedName name : qNames) { - if (result == null || name.getComponentCount() < result.getComponentCount()) { - result = name; - } - } - return result; + return qNames.stream().min((o1, o2) -> o1.getComponentCount() - o2.getComponentCount()).orElse(null); } @Nullable