public String complete(String command, Modes mode){
        String result = null;
        String cmds[] = command.split(" +");
        
        if(command.endsWith(" ")){
            result = command;
        }
        else{
            CommandNode node = root;
            for(int i=0; i<cmds.length && node!=null && node.modes.isContain(mode); i++){
                node = node.getNode(cmds[i], mode);
                if(node != null && i==cmds.length-1){
                    result = node.getName();
                }
            }
            if(result!=null){
                result = command.substring(0, command.length()-cmds[cmds.length-1].length()) + result;
            }
        }
        return result;
    }