Animated Planeswalkers
Ok, so the creature is attacking Liliana. Even with trample, the controller can choose to assign all 4 damage to Liliana. So, the controller gains 4 life.

Also, even if you decided to trample the damage over, it would still go to hit Liliana (she wouldn't be dead yet), since all damage is dealt simultaneously.  

What's interesting about the scenario is that Liliana is marked for damage as a creature AND loyalty is also removed for each point of damage.