import com.sun.corba.se.spi.orbutil.fsm.FSM;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class FSTree {
    private FSNode root;

    public FSTree() {
        this.root = new FSNode();
    }

    public void addNode(String path) throws Exception {
        if (!checkPath(path)) throw new Exception("invalid path ‘" + path + "’");

        String nodes[] = splitPath(path);
        if (nodes.length == 1) root.addChild(nodes[0]);
        else {
            FSNode target = root;
            for (String node : Arrays.copyOfRange(nodes, 0, nodes.length - 1)) {
                target = target.getChild(node);
                if (target == null) throw new Exception("no such file or directory ‘" + path + "’");
            }
            target.addChild(nodes[nodes.length - 1]);
        }
    }

    public void delNode(String path) throws Exception {
        if (!checkPath(path)) throw new Exception("invalid path ‘" + path + "’");

        try {
            FSNode target = getNode(path);
            target.autoDelete();
        } catch (Exception e) {
            throw e;
        }
    }

    public FSNode getNode(String path) throws Exception {
        String nodes[] = splitPath(path);
        FSNode target = root;
        for (String node : nodes) {
            target = target.getChild(node);
            if (target == null) throw new Exception("no such file or directory ‘" + path + "’");
        }
        return target;
    }

    public void printTree() {
        printTree(root, "/");
    }

    private void printTree(FSNode current, String absolutePath) {
        System.out.println(absolutePath);
        for (FSNode node : current.getChilds())
            printTree(node, absolutePath + node.getName() + "/");
    }

    private boolean checkPath(String path) {
        String valid_path = "^/([^/ ]+(/)?)+$";
        if (path.matches(valid_path)) return true;
        return false;
    }

    private String[] splitPath(String path) {
        return path.replaceAll("^/", "").replaceAll("/$", "").split("/");
    }
}

class FSNode {
    private String name;
    private FSNode parent;
    private List<FSNode> childs;

    public FSNode() {
        this.name = "root";
        this.parent = null;
        this.childs = new ArrayList<FSNode>();
    }

    public FSNode(String name, FSNode parent) {
        this.name = name;
        this.parent = parent;
        this.childs = new ArrayList<FSNode>();
    }

    public String getName() {
        return name;
    }

    public FSNode getParent() {
        return parent;
    }

    public List<FSNode> getChilds() {
        return childs;
    }

    public List<String> getChildsNames() {
        return childs.stream().map(FSNode::getName).collect(Collectors.toList());
    }

    public void addChild(String name) {
        FSNode child = new FSNode(name, this);
        childs.add(child);
    }

    public void delChild(String name) {
        FSNode child = getChild(name);
        childs.remove(child);
    }

    public void autoDelete() {
        parent.childs.remove(this);
    }

    public FSNode getChild(String name) {
        for (FSNode child : childs)
            if (child.name.equals(name)) return child;
        return null;
    }
}

@@ -1,50 +1,4 @@
-import com.sun.corba.se.spi.orbutil.fsm.FSM;%0A%0A
 impo
@@ -224,28 +224,31 @@
 %0A    public 
-void
+boolean
  addNode(Str
@@ -261,109 +261,9 @@
 th) 
-throws Exception %7B%0A        if (!checkPath(path)) throw new Exception(%22invalid path %E2%80%98%22 + path + %22%E2%80%99%22);%0A
+%7B
 %0A   
@@ -331,16 +331,37 @@
 th == 1)
+ %7B%0A            return
  root.ad
@@ -390,24 +390,18 @@
     
-else %7B%0A 
+%7D%0A
         
    F
@@ -388,35 +388,32 @@
       %7D%0A        
-   
 FSNode target = 
@@ -414,28 +414,24 @@
 get = root;%0A
-    
         for 
@@ -499,36 +499,32 @@
 ) %7B%0A            
-  
-  
 target = target.
@@ -543,36 +543,32 @@
 e);%0A            
-    
 if (target == nu
@@ -575,77 +575,22 @@
 ll) 
-throw new Exception(%22no such file or directory %E2%80%98%22 + path + %22%E2%80%99%22);%0A    
+return false;%0A
     
@@ -595,35 +595,38 @@
       %7D%0A        
-   
+return
  target.addChild
@@ -648,34 +648,24 @@
 ngth - 1%5D);%0A
-        %7D%0A
     %7D%0A%0A    p
@@ -666,28 +666,31 @@
 %0A    public 
-void
+boolean
  delNode(Str
@@ -703,128 +703,10 @@
 th) 
-throws Exception %7B%0A        if (!checkPath(path)) throw new Exception(%22invalid path %E2%80%98%22 + path + %22%E2%80%99%22);%0A%0A        try %7B%0A    
+%7B%0A
     
@@ -752,95 +752,77 @@
     
-    
+if (
 target
-.autoDelete();%0A        %7D catch (Exception e) %7B%0A            throw e;%0A        %7D
+ == null) return false;%0A        return target.autoDelete();
 %0A   
@@ -868,26 +868,39 @@
 th) 
-throws Exception %7B
+%7B%0A        FSNode target = root;
 %0A   
@@ -942,38 +942,8 @@
 h);%0A
-        FSNode target = root;%0A
     
@@ -1054,71 +1054,19 @@
 ll) 
-throw new Exception(%22no such file or directory %E2%80%98%22 + path + %22%E2%80%99%22)
+return null
 ;%0A  
@@ -1403,181 +1403,8 @@
  %7D%0A%0A
-    private boolean checkPath(String path) %7B%0A        String valid_path = %22%5E/(%5B%5E/ %5D+(/)?)+$%22;%0A        if (path.matches(valid_path)) return true;%0A        return false;%0A    %7D%0A%0A
     
@@ -2250,20 +2250,23 @@
  public 
-void
+boolean
  addChil
@@ -2333,24 +2333,31 @@
 s);%0A        
+return 
 childs.add(c
@@ -2381,20 +2381,23 @@
  public 
-void
+boolean
  delChil
@@ -2460,16 +2460,64 @@
         
+if (child == null) return false;%0A        return 
 childs.r
@@ -2548,20 +2548,23 @@
  public 
-void
+boolean
  autoDel
@@ -2579,16 +2579,23 @@
         
+return 
 parent.c

Return booleans to indicate success of the methods