public ArrayList<UndoableItem> undoFunction() {
        ArrayList<UndoableItem> toReturn = new ArrayList<>();
        if (undoStack.isEmpty()) {
            return null;
        } else {
            ArrayList<UndoableItem> cur = (ArrayList<UndoableItem>) this.undoStack.pop();

            this.redoStack.push(cur);
            for (UndoableItem ui : cur) {
                toReturn.add(ui);
                if (ui.getDitem() instanceof Panel) {
                    //  for (Layer l : ((Panel) cur.getDitem()).getLayers()) {
                    for (PathItem pi : ((Panel) ui.getDitem()).getLines()) {
                        if (!pi.isHidden()) {
                            toReturn.add(new UndoableItem(pi, ui.getActionType()));
                        }
                    }
                    // }
                }
            }
            return toReturn;
        }

    }