In modern browsers, you need only very little to code to create a collapsible tree :
var tree = document.querySelectorAll('ul.tree a:not(:last-child)');_x000D_
for(var i = 0; i < tree.length; i++){_x000D_
tree[i].addEventListener('click', function(e) {_x000D_
var parent = e.target.parentElement;_x000D_
var classList = parent.classList;_x000D_
if(classList.contains("open")) {_x000D_
classList.remove('open');_x000D_
var opensubs = parent.querySelectorAll(':scope .open');_x000D_
for(var i = 0; i < opensubs.length; i++){_x000D_
opensubs[i].classList.remove('open');_x000D_
}_x000D_
} else {_x000D_
classList.add('open');_x000D_
}_x000D_
e.preventDefault();_x000D_
});_x000D_
}
_x000D_
body {_x000D_
font-family: Arial;_x000D_
}_x000D_
_x000D_
ul.tree li {_x000D_
list-style-type: none;_x000D_
position: relative;_x000D_
}_x000D_
_x000D_
ul.tree li ul {_x000D_
display: none;_x000D_
}_x000D_
_x000D_
ul.tree li.open > ul {_x000D_
display: block;_x000D_
}_x000D_
_x000D_
ul.tree li a {_x000D_
color: black;_x000D_
text-decoration: none;_x000D_
}_x000D_
_x000D_
ul.tree li a:before {_x000D_
height: 1em;_x000D_
padding:0 .1em;_x000D_
font-size: .8em;_x000D_
display: block;_x000D_
position: absolute;_x000D_
left: -1.3em;_x000D_
top: .2em;_x000D_
}_x000D_
_x000D_
ul.tree li > a:not(:last-child):before {_x000D_
content: '+';_x000D_
}_x000D_
_x000D_
ul.tree li.open > a:not(:last-child):before {_x000D_
content: '-';_x000D_
}
_x000D_
<ul class="tree">_x000D_
<li><a href="#">Part 1</a>_x000D_
<ul>_x000D_
<li><a href="#">Item A</a>_x000D_
<ul>_x000D_
<li><a href="#">Sub-item 1</a></li>_x000D_
<li><a href="#">Sub-item 2</a></li>_x000D_
<li><a href="#">Sub-item 3</a></li>_x000D_
</ul>_x000D_
</li>_x000D_
<li><a href="#">Item B</a>_x000D_
<ul>_x000D_
<li><a href="#">Sub-item 1</a></li>_x000D_
<li><a href="#">Sub-item 2</a></li>_x000D_
<li><a href="#">Sub-item 3</a></li>_x000D_
</ul>_x000D_
</li>_x000D_
<li><a href="#">Item C</a>_x000D_
<ul>_x000D_
<li><a href="#">Sub-item 1</a></li>_x000D_
<li><a href="#">Sub-item 2</a></li>_x000D_
<li><a href="#">Sub-item 3</a></li>_x000D_
</ul>_x000D_
</li>_x000D_
<li><a href="#">Item D</a>_x000D_
<ul>_x000D_
<li><a href="#">Sub-item 1</a></li>_x000D_
<li><a href="#">Sub-item 2</a></li>_x000D_
<li><a href="#">Sub-item 3</a></li>_x000D_
</ul>_x000D_
</li>_x000D_
<li><a href="#">Item E</a>_x000D_
<ul>_x000D_
<li><a href="#">Sub-item 1</a></li>_x000D_
<li><a href="#">Sub-item 2</a></li>_x000D_
<li><a href="#">Sub-item 3</a></li>_x000D_
</ul>_x000D_
</li>_x000D_
</ul>_x000D_
</li>_x000D_
_x000D_
<li><a href="#">Part 2</a>_x000D_
<ul>_x000D_
<li><a href="#">Item A</a>_x000D_
<ul>_x000D_
<li><a href="#">Sub-item 1</a></li>_x000D_
<li><a href="#">Sub-item 2</a></li>_x000D_
<li><a href="#">Sub-item 3</a></li>_x000D_
</ul>_x000D_
</li>_x000D_
<li><a href="#">Item B</a>_x000D_
<ul>_x000D_
<li><a href="#">Sub-item 1</a></li>_x000D_
<li><a href="#">Sub-item 2</a></li>_x000D_
<li><a href="#">Sub-item 3</a></li>_x000D_
</ul>_x000D_
</li>_x000D_
<li><a href="#">Item C</a>_x000D_
<ul>_x000D_
<li><a href="#">Sub-item 1</a></li>_x000D_
<li><a href="#">Sub-item 2</a></li>_x000D_
<li><a href="#">Sub-item 3</a></li>_x000D_
</ul>_x000D_
</li>_x000D_
<li><a href="#">Item D</a>_x000D_
<ul>_x000D_
<li><a href="#">Sub-item 1</a></li>_x000D_
<li><a href="#">Sub-item 2</a></li>_x000D_
<li><a href="#">Sub-item 3</a></li>_x000D_
</ul>_x000D_
</li>_x000D_
<li><a href="#">Item E</a>_x000D_
<ul>_x000D_
<li><a href="#">Sub-item 1</a></li>_x000D_
<li><a href="#">Sub-item 2</a></li>_x000D_
<li><a href="#">Sub-item 3</a></li>_x000D_
</ul>_x000D_
</li>_x000D_
</ul>_x000D_
</li>_x000D_
_x000D_
<li><a href="#">Part 3</a>_x000D_
<ul>_x000D_
<li><a href="#">Item A</a>_x000D_
<ul>_x000D_
<li><a href="#">Sub-item 1</a></li>_x000D_
<li><a href="#">Sub-item 2</a></li>_x000D_
<li><a href="#">Sub-item 3</a></li>_x000D_
</ul>_x000D_
</li>_x000D_
<li><a href="#">Item B</a>_x000D_
<ul>_x000D_
<li><a href="#">Sub-item 1</a></li>_x000D_
<li><a href="#">Sub-item 2</a></li>_x000D_
<li><a href="#">Sub-item 3</a></li>_x000D_
</ul>_x000D_
</li>_x000D_
<li><a href="#">Item C</a>_x000D_
<ul>_x000D_
<li><a href="#">Sub-item 1</a></li>_x000D_
<li><a href="#">Sub-item 2</a></li>_x000D_
<li><a href="#">Sub-item 3</a></li>_x000D_
</ul>_x000D_
</li>_x000D_
<li><a href="#">Item D</a>_x000D_
<ul>_x000D_
<li><a href="#">Sub-item 1</a></li>_x000D_
<li><a href="#">Sub-item 2</a></li>_x000D_
<li><a href="#">Sub-item 3</a></li>_x000D_
</ul>_x000D_
</li>_x000D_
<li><a href="#">Item E</a>_x000D_
<ul>_x000D_
<li><a href="#">Sub-item 1</a></li>_x000D_
<li><a href="#">Sub-item 2</a></li>_x000D_
<li><a href="#">Sub-item 3</a></li>_x000D_
</ul>_x000D_
</li>_x000D_
</ul>_x000D_
</li>_x000D_
</ul>
_x000D_
(see also this Fiddle)