You can "filter" out the lines that are introduced because of the tree in the original image, by rejecting "any set of lines / line segments that doesn't compose a rectangular window". In this way and under specific conditions you might even be able to "fill in" the parts of windows that are currently only partially visible.
The technique is based on the detection of rectangular features via the use of the Hough Transform.
The Hough Transform is composed by integrating image profiles along different directions. Therefore, where the original image has dimensions of space (usually $x,y$), the transformation's output has dimensions of displacement, angle. The effect of this transform, over purely binary images, is to convert lines / line segments (characterised by some $x_1,y_1$,$x_2,y_2$ coordinates) to points (that is, "Detected a very high value of the integral along direction $\theta$). The output of the Hough Transform is still "usable" for grayscale images in the presence of noise and in-fact there, depending on the length of a "line" versus the amount of noise in the image, the Hough Transform can discover lines in very bad conditions.
Because of this property, various detectors have been established on the output of the Hough Transform to detect basic geometrical shapes such as circles and rectangles.
The Hough Transform is very relevant to this problem because it can operate over the output of the edge detector to detect the windows.
By creating the model of an "ideal window" and obtaining its Hough Transform, you can establish the set of points (in the Hough space) that correspond to the lines that make up the window.
Then, obtaining an image from the real world, you can mine its Hough space for geometric configurations of points that make up windows.
This step will detect whole windows. Having detected those, you can then mine the Hough Space for sets of points that seem to be making up a window, had there been a few more points at predicted spaces. You can then establish a heuristic to decide what would constitute a good partially discovered window. This could be a "prediction" step.
In this way, you would be rejecting all of these smaller incoherent lines that tend to make up the tree and foliage.
For more information on detecting rectangles using the Hough Transform, please see this publication. For more information on using the Hough Transform to detect shapes, try a search for "Hough Transform, shape detection" or see this link and this link.
Hope this helps.