ASTNode (ASTNode baseNode, TokenSet targetTypes) { if (targetTypes.contains(baseNode.getElementType())) { return baseNode; } for (ASTNode node = baseNode; node != null; node = node.getFirstChildNode()) { IElementType nodeType = node.getElementType(); if (targetTypes.contains(nodeType)) { return node; } } return null; }