Same entity controlling separated parts of a a lightning path Given the lightning path Alice → Bob → Carol → Dave → Emilee (with Alice being the sender and Emilee being the receiver), assume Dave and Bob to be the same entity.

By pulling funds from Dave to herself, Emilee discloses the secret R to Dave. Bob then knows R, too, because Bob and Dave are the same entity, and pulls funds from Alice.

Bob then broadcasts the channels state between him and Carol to the blockchain. Dave subsequently pulls funds from Carol.

In this procedure, Carol did not get paid. How is this prevented?
The preimage R is the same throughout the entire route, so Bob/Dave would know what R is (from lnd Overview).

However if Bob were to broadcast his commitment transaction for the Bob -&gt; Carol channel, it would have to either be an old commitment without the HTLC-offered output or be the current commitment transaction with the HTLC-offered output. In the case of an old commitment transaction, Carol would be able to claim all of the funds in the channel with the revocation key for the old commitment transaction.

In the case of the second transaction with the offered HTLC output, the offered HTLC output has a timeout on it which prevents Bob from spending the funds for some amount of time, say two days. In that time, Carol could redeem those funds with the preimage R.

In order for Bob/Dave to pull funds from Carol in the Carol -&gt; Dave channel, he would need to give Carol R before the HTLC between Carol and Dave times out. The timeout of this HTLC will be shorter than the HTLC between Bob and Carol (e.g. only 1 day) so when Dave gives Carol R to pull his funds (or R is published in Dave's broadcast commitment transaction if he does that), Carol can then use that R to claim her funds from Bob's offered HTLC output.

In the event that Dave decides to not pull funds from Carol, Carol retracts her HTLC output after it times out and does not lose any money to Dave. She does not then gain any money from Bob and thus has not lost any money at all. 

If Dave refused to sign the new commitment transaction, Carol broadcasts her commitment with the Carol -&gt; Dave offered HTLC after the timeout passes and publishes a transaction which spends the offered HTLC output using the HTLC-timeout transaction. If Dave tries to spend the HTLC using R, Carol then learns of R and can then spend Bob's offered HTLC output using said R. In that case, Bob/Dave can actually lose money because Carol's HTLC-timeout transaction could confirm before Dave's HTLC-Sucess transaction (which contains R) and her HTLC-Success transaction for Bob's HTLC could confirm before Bob's HTLC-Timeout and thus gain money from Bob/Dave.

Thus such a scheme would result in Carol effectively being cut out of the route and not losing any money. If Bob/Dave were stupid, they could actually lose money to Carol.