Rework inheritance behaviour of plans.
Remove duplicated execution timing code.
Fix timing for finding best plan.
Rename cast_to_plan() to cast_to_parent() and make inline.