void (@NotNull TreePath path, boolean canSmartExpand) { Object last = path.getLastPathComponent(); boolean isLeaf = myTree.getModel().isLeaf(path.getLastPathComponent()); boolean isRoot = last == myTree.getModel().getRoot(); TreePath parent = path.getParentPath(); if (isRoot && !myTree.isExpanded(path)) { if (myTree.isRootVisible() || myUnbuiltNodes.contains(last)) { insertLoadingNode((DefaultMutableTreeNode)last, false); } expandPath(path, canSmartExpand); } else if (myTree.isExpanded(path) || isLeaf && parent != null && myTree.isExpanded(parent) && !myUnbuiltNodes.contains(last) && !isCancelled(last)) { if (last instanceof DefaultMutableTreeNode) { processNodeActionsIfReady((DefaultMutableTreeNode)last); } } else { if (isLeaf && (myUnbuiltNodes.contains(last) || isCancelled(last))) { insertLoadingNode((DefaultMutableTreeNode)last, true); expandPath(path, canSmartExpand); } else if (isLeaf && parent != null) { DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode)parent.getLastPathComponent(); if (parentNode != null) { addToUnbuilt(parentNode); } expandPath(parent, canSmartExpand); } else { expandPath(path, canSmartExpand); } } }