QualifiedName (@NotNull PyQualifiedExpression expr) { final List<String> path = new LinkedList<>(); final String firstName = expr.getReferencedName(); if (firstName == null) { return null; } path.add(firstName); PyExpression qualifier = expr.getQualifier(); while (qualifier != null) { final PyReferenceExpression qualifierReference = ObjectUtils.tryCast(qualifier, PyReferenceExpression.class); if (qualifierReference == null) { return null; } final String qualifierName = qualifierReference.getReferencedName(); if (qualifierName == null) { return null; } path.add(0, qualifierName); qualifier = qualifierReference.getQualifier(); } return QualifiedName.fromComponents(path); }