ASTNode (ASTNode node) { if (node == null) return null; if (!isWhitespaceOrComment(node)) return node; ASTNode parent = node.getTreeParent(); ASTNode prev = node; while (prev instanceof CompositeElement) { if (!isWhitespaceOrComment(prev)) return prev; prev = prev.getTreePrev(); } if (prev == null) return null; ASTNode firstChildNode = parent.getFirstChildNode(); ASTNode lastRelevant = null; while (firstChildNode != prev) { if (!isWhitespaceOrComment(firstChildNode)) lastRelevant = firstChildNode; firstChildNode = firstChildNode.getTreeNext(); } return lastRelevant; }