ModuleNode (ASTNode node) { if (node instanceof ModuleNode) { return (ModuleNode)node; } if (node instanceof ClassNode) { return ((ClassNode)node).getModule(); } if (node instanceof AnnotatedNode) { ClassNode declaringClass = ((AnnotatedNode)node).getDeclaringClass(); if (declaringClass != null) { return declaringClass.getModule(); } } return null; }