Included pythonic version of algorithm currently implemented in GADGET.