delete layers if image is removed

all layers are removed until an image is found in the hierarchy. this
does not take into account that multiple images can reference the same
layers.
Merge pull request #1 from teemow/delete-graph-layers

Delete unreferenced layers if an image is removed