class BaseObject implements Serializable, Cloneable, InputLocationTracker {
    protected transient ChildrenTracking childrenTracking;

    protected Object delegate;

    public BaseObject() {}

    public BaseObject(Object delegate, BaseObject parent) {
        this.delegate = delegate;
        this.childrenTracking = parent != null ? parent::replace : null;
    }

    public BaseObject(Object delegate, ChildrenTracking parent) {
        this.delegate = delegate;
        this.childrenTracking = parent;
    }

    public Object getDelegate() {
        return delegate;
    }

    public void update(Object newDelegate) {<FILL_FUNCTION_BODY>}

    protected boolean replace(Object oldDelegate, Object newDelegate) {
        return false;
    }

    @FunctionalInterface
    protected interface ChildrenTracking {
        boolean replace(Object oldDelegate, Object newDelegate);
    }
}

        if (delegate != newDelegate) {
            if (childrenTracking != null) {
                childrenTracking.replace(delegate, newDelegate);
            }
            delegate = newDelegate;
        }
    
<no_super_class>