Updated the `extend` function to return `object to extends` value if it is empty or the objects to extend with are empty.
Merged latest.