String () { final PyImportElementStub stub = getStub(); if (stub != null) { final String asName = stub.getAsName(); if (!StringUtil.isEmpty(asName)) { return asName; } final QualifiedName importedName = stub.getImportedQName(); if (importedName != null && importedName.getComponentCount() > 0) { return importedName.getComponents().get(0); } } else { PyTargetExpression asNameElement = getAsNameElement(); if (asNameElement != null) { return asNameElement.getName(); } final QualifiedName importedName = getImportedQName(); if (importedName != null && importedName.getComponentCount() > 0) { return importedName.getComponents().get(0); } } return null; // we might have not found any names }