Section 18. If a legacy subject to said tax is charged upon or payable out of real estate, the heir or devisee, before paying said legacy, shall deduct said tax therefrom and pay it to the executor, administrator or trustee, and the tax shall remain a lien upon said real estate until it is paid. Payment thereof may be enforced by the executor, administrator or trustee in the same manner as the payment of the legacy itself could be enforced.