Recursion appears to work appropriately.
Test cases from Fegaras' paper included.