PyCallExpression (@NotNull PyFile file) { final Ref<PyCallExpression> result = new Ref<>(null); file.acceptChildren(new PyRecursiveElementVisitor() { @Override public void visitPyCallExpression(@NotNull PyCallExpression node) { final PyExpression callee = node.getCallee(); final String name = PyUtil.getReadableRepr(callee, true); if ("setup".equals(name)) { result.set(node); } } @Override public void visitPyElement(@NotNull PyElement node) { if (!(node instanceof ScopeOwner)) { super.visitPyElement(node); } } }); return result.get(); }