fix: removing orphaned connectors
diff --git a/erpnext/public/js/hierarchy_chart/hierarchy_chart_desktop.js b/erpnext/public/js/hierarchy_chart/hierarchy_chart_desktop.js
index 9e82fb2..1896ac7 100644
--- a/erpnext/public/js/hierarchy_chart/hierarchy_chart_desktop.js
+++ b/erpnext/public/js/hierarchy_chart/hierarchy_chart_desktop.js
@@ -176,8 +176,8 @@
 
 	collapse_node() {
 		if (this.selected_node.expandable) {
-			this.selected_node.$children.hide('fast');
-			$(`path[data-parent="${this.selected_node.id}"]`).hide('fast');
+			this.selected_node.$children.hide();
+			$(`path[data-parent="${this.selected_node.id}"]`).hide();
 			this.selected_node.expanded = false;
 		}
 	}
@@ -237,8 +237,8 @@
 			}
 		}
 
-		node.$children.show('fast');
-		$(`path[data-parent="${node.id}"]`).show('fast');
+		node.$children.show();
+		$(`path[data-parent="${node.id}"]`).show();
 		node.expanded = true;
 	}
 
@@ -262,9 +262,7 @@
 		let parent_node = document.querySelector(`#${parent_id}`);
 		let child_node = document.querySelector(`#${child_id}`);
 
-		// variable for the namespace
-		const svgns = 'http://www.w3.org/2000/svg';
-		let path = document.createElementNS(svgns, 'path');
+		let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
 
 		// we need to connect right side of the parent to the left side of the child node
 		let pos_parent_right = {
@@ -438,7 +436,7 @@
 			let parent = $(path).data('parent');
 			let child = $(path).data('child');
 
-			if ($(parent).length || $(child).length)
+			if ($(`#${parent}`).length && $(`#${child}`).length)
 				return;
 
 			$(path).remove();
diff --git a/erpnext/public/js/hierarchy_chart/hierarchy_chart_mobile.js b/erpnext/public/js/hierarchy_chart/hierarchy_chart_mobile.js
index 2ff00ba..102cbb0 100644
--- a/erpnext/public/js/hierarchy_chart/hierarchy_chart_mobile.js
+++ b/erpnext/public/js/hierarchy_chart/hierarchy_chart_mobile.js
@@ -289,9 +289,7 @@
 		let parent_node = document.querySelector(`#${parent_id}`);
 		let child_node = document.querySelector(`#${child_id}`);
 
-		// variable for the namespace
-		const svgns = 'http://www.w3.org/2000/svg';
-		let path = document.createElementNS(svgns, 'path');
+		let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
 
 		let connector = undefined;
 
@@ -514,7 +512,7 @@
 			let parent = $(path).data('parent');
 			let child = $(path).data('child');
 
-			if ($(parent).length || $(child).length)
+			if ($(`#${parent}`).length && $(`#${child}`).length)
 				return;
 
 			$(path).remove();