This is similar to the Selection.getContaining method. Could they be merged?