boolean (KtExpression parent, KtExpression child) { if (parent == null || child == null) { return false; } while (parent != child) { PsiElement childParent = child.getParent(); if (childParent instanceof KtParenthesizedExpression) { child = (KtExpression) childParent; continue; } if (childParent instanceof KtDotQualifiedExpression && (child instanceof KtCallExpression || child instanceof KtDotQualifiedExpression)) { child = (KtExpression) childParent; continue; } child = getParentForBranch(child); if (child == null) return false; } return true; }