Fixes for MOB-836 and MOB-766.

https://edx-wiki.atlassian.net/browse/MOB-836
https://edx-wiki.atlassian.net/browse/MOB-766

*Note:* I've been meaning to update the unit tests for these changes.  But wanted to start the review process as soon as possible.  I'll try to work on the tests later tonight.

@ormsbee Can you take a look through this? 
@waheedahmed I would appreciate a review from your side since you are familiar with the video code.
@adampalay FYI.
nvm.  I now see that this code is written as a depth-first search.  I have now moved the check up (before line 89).