private void disconnectSubTree(final ExplorerTreeNode node) {
        final List<ExplorerTreePath> pathsToRemove = JooqUtil.contextResult(explorerDbConnProvider, context ->
                        context
                                .selectFrom(p)
                                .where(p.DESCENDANT.in(context
                                        .select(p1.DESCENDANT)
                                        .from(p1)
                                        .where(p1.ANCESTOR.eq(node.getId()))))
                                .and(p.ANCESTOR.notIn(context
                                        .select(p2.DESCENDANT)
                                        .from(p2)
                                        .where(p2.ANCESTOR.eq(node.getId()))))
                                .fetch())
                .map(ExplorerTreeDaoImpl::mapExplorerPathRecord);

        List<ExplorerTreePath> pathSiblings = getAllTreePathSiblings(node.getId());
        int oldPosition = -1;

        for (final ExplorerTreePath path : pathsToRemove) {
            removePath(path);
            if (path.getDepth() == 1) {
                oldPosition = path.getOrderIndex();
            }
        }

        closeGap(pathSiblings, oldPosition);
    }
Get the root node containing a particular node, or the node itself if it is a root node.
stroom-explorer/stroom-explorer-impl-db/src/main/java/stroom/explorer/impl/db/ExplorerTreeDaoImpl.java