The exact same thing happens in a refinery. The petroleum or crude oil is heated. Then the vapor goes into a fractionating tower. It takes the crude oil and breaks it into parts or fractions. In this fractionating tower, the lightest vapors rise to the top while the heavier vapors stay at the bottom.
Several pans collect the vapor as it turns back into liquid.
Different liquids are formed at different levels of the tower. The vapor that condenses at the very top of the tower is used not only for gasoline and kerosene, but also for a variety of products. These products are called petrochemicals. Chemists change the molecules in the petroleum and create many new products. Many of these petroleum products are found in the home.