State (final CheckedTreeNode node) { State ownState = node.isChecked() ? State.SELECTED : State.NOT_SELECTED; if (myIgnoreInheritance || node.getChildCount() == 0 || !myUsePartialStatusForParentNodes) { return ownState; } State result = null; for (int i = 0; i < node.getChildCount(); i++) { TreeNode child = node.getChildAt(i); State childStatus = child instanceof CheckedTreeNode? getNodeStatus((CheckedTreeNode)child) : ownState; if (childStatus == State.DONT_CARE) return State.DONT_CARE; if (result == null) { result = childStatus; } else if (result != childStatus) { return State.DONT_CARE; } } return result == null ? ownState : result; }