Imam can be served as a luncheon entrée with a green salad and warm bread, or as part of a mezze spread. If making ahead of time and refrigerating, bring it to room temperature, or warm it very slightly in the oven before serving, as the oil tends to congeal on standing.
2. Preheat the oven to 350°F. Halve two of the tomatoes, squeeze out the seeds, and grate them on the large holes of a box grater, discarding the skins. Reserve. Remove the seeds from the other two tomatoes and cut them into medium dice.
3. Heat 3 tablespoons of the oil in a large, shallow ovenproof casserole or Dutch oven. Sauté the onions over medium-low heat, stirring, until soft but not brown, about 10 minutes. Stir in the garlic and tomatoes, both grated and diced, and arrange the eggplants among the onions so that they touch the bottom of the casserole. Pour in the rest of the olive oil. Cover and cook over medium-low heat for 10 minutes, turning the eggplants once.
4. Mix the water with the sugar, pour over the eggplants, add salt to taste and transfer the casserole, covered, to the oven. Bake for 35 minutes, turning the eggplants every 10 minutes or so. At the end of cooking, all the water should be absorbed and the cooking liquid (oil and tomato juices) should be glossy and caramelized.
5. Cool the eggplant to a slightly warm or room temperature. Before serving, make a long lengthwise slit in each eggplant and push about 1-1/2 tablespoons of the onion-garlic mixture into the slits, draining it on a fork as you stuff. With a spatula, carefully transfer the eggplants to a serving platter, spoon the sauce around them, and sprinkle with parsley and pine nuts. Squeeze some of the lemon juice on top, to taste. Serve garnished with additional lemon wedges.